Closed pcmicro closed 4 years ago
As a workaround, try to run your .bat file with command /c i.e. command /c mybat.bat
When I tried your suggestion from the command prompt, it works as it should. Interestingly I first tried a hardcoded path like this: c:\windows\system32\command.com /s c:\path\test.bat And this produced the following result: Invalid switch Specified COMMAND search directory bad Microsoft(R) Windows NT DOS (C)Copyright Microsoft Corp 1990-1996.
If I simply run test.bat from the command prompt I don't see the above result, or the reported issue, so it works fine this way. I do see the issue when I launch the batch file from my application, using CreateProcess like so:
LOCAL sinfo:STARTUPINFO LOCAL pinfo:PROCESS_INFORMATION
invoke memfill, ADDR pinfo, sizeof SINFO, 0 ; Zero fill pinfo
invoke memfill, ADDR pinfo, sizeof SINFO, 0 ; Zero fill sinfo
xor ecx,ecx
invoke CreateProcess, ecx, lpfilename, ecx, ecx, TRUE,
CREATE_NEW_CONSOLE Or NORMAL_PRIORITY_CLASS,
ecx, lppath, addr sinfo, addr pinfo
I can send full source code if it is helpful.
To:pcmicro
c:\windows\system32\command.com /s c:\path\test.bat
No "/s" switch
C:>command/? Starts a new instance of the MS-DOS command interpreter.
COMMAND [[drive:]path] [device] [/E:nnnnn] [/P] [/C string] [/MSG]
[drive:]path Specifies the directory containing COMMAND.COM file. device Specifies the device to use for command input and output. /E:nnnnn Sets the initial environment size to nnnnn bytes. /P Makes the new command interpreter permanent (can't exit). /C string Carries out the command specified by string, and then stops. /MSG Specifies that all error messages be stored in memory. You need to specify /P with this switch.
I test OK. command.com /c test.bat c:\windows\system32\command.com /c k:\dos\test.bat
Duh, I somehow tried with /s instead of /c that day and just realized it... Yes I see that this workaround avoids the issue, but hopefully the issue can be fixed.
When a batch file encounters a DOS program that is a TSR (Terminate and Stay Resident), after the programs runs, the .bat file aborts immediately instead of continuing to the next line in the batch file.. A good example of a TSR would be ANSI.COM.