Question:I need help with understanding the following Batch script structure:
This is named Profile_something_schedule.bat
- I do not know why the 3rd line is valid. The behavior produced is that the someFileName is run. I understand it as starting the file as a process. Then why isn’t the start command needed? I don’t see any batch documentation saying you can simply run a file by writing its pathed filename.
- I do not understand the syntax of “%~someFileName”. From online searching about it almost every source shows you the batch call parameter table, saying things like %~1 expands %1…, %~f1 expands %1 some other way, etc. All of them involve some kind of number from 0 to 9 to correspond to the parameter position. However, I cannot find any specification of %~someString being legal. There is no parameter positional information from the someFileName string, it is a filename.extension string. Still, it is quite likely this line is trying to run this format.
- What does “/vv_pwd=%reqKey% /bProfile_something_schedule” mean? In the lib.cmd that was called previously, there were variables reqPath and reqKey and I am quite certain it is trying to pass the value of reqPath and reqKey from the lib.cmd into the variables here and then I guess it is trying to use the reqKey value as a parameter, which is a password required to run the file. Inspecting the file, it contains some script of some paid software specific format, it only has variable name v_pwd inside but not vv_pwd. I do not know what the /bProfile_… is for. The part without the /b is exactly this batch file’s name. But together with the /b I don’t know what it means. The /v and /b look like some kind of options to me but I cannot see any specification explaining as there is no command beginning line 3 just some path. I guess the /min option refers to starting window minimized which is an option for the command start, yet there is no option of /v. The /B in start means to start application without creating window, which is quite unnecessary to have /min if you are not going to create a window in the first place. And it doesn’t make sense to use /B directly followed by some string of Profile_something_Schedule.
FYI, the lib.cmd starts with call %*, which I would consider as trying to call all passed parameters and assuming those parameters are actually batch files that can be called. Another thought I have is that the 2nd line call connects with the 3rd line so the 3rd line may not need a command. But I can’t make sense of it. The someFileName is not of the Batch extension so I doubt it can be called as the call doc says it is for batch programs. If I want to run non-batch programs I need to use start right?
Would greatly appreciate your help!
pathextcontains a semicolon-separated list of executable filenames that may be appended as an extension to
myexecutable. if the first string on a batch line is not a
cmdinternal command (like
cmdtries to find
myexecutable+ each of the extensions in
pathextin turn, first in the current directory, and then in each directory in the
path(another semicolon-separated list of directories) and runs the first name found, or fails if none are found. That first string may also have an
Associatedextension, which then runs the application with which the extension is
Neither do I, and I can’t see that even knowing what the actual strings being executed by
%reqPath%are would assist. See
for /?from the prompt for more documentation on other
~operators – or search SO for thousands of uses.
%reqKey%is replaced by the value of the variable
reqKeyevidently returned by the previous line.
/is used in Windows to mean “here’s a switch parameter for the executable”, so evidently
/vv_pwd=[the contents of reqKey],
/minmean something to the executable
%reqPath%. Quite what is anyone’s guess.
The fact that
lib.cmd‘s first line is
call %*would mean that
lib.cmdcontains a library of routines. Since each
callyou have shown is of the form
:string1 string2then the resultant command executed would be
call :string1 string2.
call :string1will call the routine contained within “lib.cmd” with the label
string2(and presumably optionally
string2 string3...as parameters. Evidently,
string2is the name of the variable into which
lib.cmdplaces the required data.
string1would be any executable that
cmdcan locate using the method in (1). It does not have to be a batch, but commonly is a batch.
If you have better answer, please add a comment about this, thank you!