The user essentially has a SYSTEM environmental variable defined as go=go.exe %~n0. The user was then trying to use that as a MACRO variable in a batch file.
Now the first thing that comes to mind is that you would need to use CALL ECHO %go% to get the variables to expand correctly. Sure enough you see the expansion of %go% and %~n0 when you watch the code execute.
But what baffles me is if you just use CALL %go%, you never see the %~n0 expand but the program that is called does actually get the name of the batch file as its command line argument.
To test this I set my system variable as go=find.exe "%~n0" %0
I then ran this batch file named go.bat
Code: Select all
@echo on
setlocal
call %go%
endlocal
pause
And the verbose output is:
Code: Select all
C:\BatchFiles\>setlocal
C:\BatchFiles>call find.exe "%~n0" %0
---------- GO.BAT
call %go%
C:\BatchFiles>endlocal
C:\BatchFiles>pause
Press any key to continue . . .
So I am completely baffled as to how the find command is seeing my search parameter and the name of my batch file as the input file name.
What is CMD.EXE doing?