I have setup a script and tested that it work with user input via set /p but now I want to pass that variable automatically to the cmd.
Script w/ user input:
@ECHO OFF
set /p
start /d "G:\Emulators\N64\Project64" Project64.exe "G:\Emulators\N64\Roms\%id%"What I want to pass to the CLI:
C:\WINDOWS\system32>set id = "Goldeneye 007.v64" & "C:\script.cmd" 6 1 Answer
You can use batch arguments and pass the value of the ROM to the call of the batch script when you execute it such as C:\script.cmd "<Value Argument>".
Rather than using set /p use set id=%~1 and that's all that is needed to allow the first argument passed to the script to be used for the value to set the id variable.
Batch Script Example
@ECHO OFF
set id=%~1
start /d "G:\Emulators\N64\Project64" Project64.exe "G:\Emulators\N64\Roms\%id%"Argument Passed to Batch Script Example
C:\script.cmd "Goldeneye 007.v64"Further Resources
Command Line arguments (Parameters)
%* in a batch script refers to all the arguments (e.g. %1 %2 %3 %4 %5 ...%255) only arguments %1 to %9 can be referenced by number.