问题
I want to make a batch file that runs a particular program and then the command window exits itself, I tried this cause i will make a shortcut of that batch file so the batch file is in root directory
@echo off
"program.exe" "mainframe.pkg"
exit
it works but the black windows doesn't disappear and causes a fuss in the program cause it has perimeters. Any way to remove the black ugly CMD window.
回答1:
Use the start command.
@echo off
start "" "program.exe" "mainframe.pkg"
The first quoted string after the start command is a console window title (if you are starting a console program); it can be an empty string as in my example. After that, specify the program name and its parameters.
You do not need the exit command at the end of the script. (In fact, I recommend against it without the /b parameter, because if you run the script from a cmd.exe prompt, your cmd.exe window will close without warning.)
回答2:
You need to add exit 0 to the end of your program like so:
@echo off
start "program.exe" "mainframe.pkg"
exit /B 0
This should work, but let me know!
来源:https://stackoverflow.com/questions/46570150/run-a-program-and-exit-the-cmd-window