- 1 year ago
Making start / priority (in a batch file) work and passing arguments from one batch file to another
To set the priority of a process using the start
command in a batch file and pass arguments from one batch file to another, follow these steps:
Setting Priority using
start
command:
Thestart
command does not provide a direct option to set the priority of the launched process. However, you can use thewmic
command to change the priority of the process after it starts. For example, to start a process with low priority, you can use the following in your batch file:batchstart /B /LOW your_command_here
The
/B
option is used to start the command without opening a new window, and/LOW
sets the process priority to low.Note: The
/LOW
option is not available on all Windows versions, and it may not be available for some specific applications.Passing Arguments between Batch Files:
You can pass arguments from one batch file to another by using the%*
syntax, which represents all the arguments passed to the current batch file. Here's an example of how you can do this:In your first batch file (
file1.bat
), call the second batch file (file2.bat
) and pass the arguments:batch@echo off
echo Running file1.bat
call file2.bat %*
In your second batch file (
file2.bat
), you can access the arguments passed fromfile1.bat
using%1
,%2
, and so on. For example:batch@echo off
echo Running file2.bat
echo Argument 1: %1
echo Argument 2: %2
When you run
file1.bat
and pass arguments to it, those arguments will be forwarded tofile2.bat
, and it will display them.Example usage:
file1.bat arg1 arg2
Output:
sqlRunning file1.bat
Running file2.bat
Argument 1: arg1
Argument 2: arg2
By using
%*
in the call statement, all the arguments passed tofile1.bat
are forwarded tofile2.bat
.
Remember to adjust the paths and commands as per your specific requirements. If you have specific requirements or face any issues, please provide more details, and I'll be happy to assist further.