I have the following batch file
REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Dependencies\{2e085fd2-a3e4-4b39-8e10-6b8d35f55244} > nul
if %ERRORLEVEL% EQU 1 (
start /wait "" "%~dp0vc_redist.x86.exe"
)
if exist "%~dp0files\data\GAME_EXE.exe" (
start "" "%~dp0files\data\GAME_EXE.exe"
) else (
SET scriptDir=%tmp%\tempGameDialog.vbs
@echo Call msgbox("It looks like your virus scanner deleted the game exe file. Please deactivate it, restore the game exe file, then try again.", vbCritical, "Error with game"^) > %scriptDir%
@cscript /nologo %scriptDir%
@del %scriptDir%
)
When I run this file through command prompt, it works without problem and I see the dialog window in the else statement as I would expect. Whenever I run the batch file through windows explorer, the command prompt closes instantly without seeing any prompt.
If I add the following line to the first line of the batch file, then run through windows explorer, then all works as you would expect
@SET scriptDir=%tmp%\tempGameDialog.vbs
I've tried using the start command to run cscript etc, but it doesn't work without the above line at the start of the batch file.
Whats the cause of this weird behavior? Why do I need to do a variable assignment on the first line for any of my script to run? Or am I missing something completley obvious.
Thanks