Batch START command just start a blank command window not run my script
So I am working on a project where I need to start another batch file, Task Options.bat from this batch file, Task.bat in the same directory, but not close or pause the original file, so this is the script of Task.bat
@ECHO off TITLE Task START /D %~dp0 "Task Options.bat" :loop TASKLIST /FI "MEMUSAGE gt 20000" timeout 10 >nul cls goto loop
Other lines are irrelevant but the third line of code: When I run the file, it just opens a blank cmd window that titled "Task Options.bat". There are codes in the Task Options.bat file so if it is being ran it would output something. So where I did wrong?
@ECHO off TITLE Task START "Options" /D %~dp0 %ComSpec% /k Options.bat :loop TASKLIST /FI "MEMUSAGE gt 20000" timeout 10 >nul cls goto loop
Note that you may want to change the /k to /c if you want the Options window to go away after the options.bat script runs. Use /k until you've got all the bugs worked out.
Your version did not work because you had the command line arguments all mixed up. This sets the console window title to Options, the starting directory path to the same directory the script is in, uses the %COMSPEC% variable to find the correct cmd.exe file and hands it the Options.bat script file name to execute.