Run a Program and exit the cmd window

99封情书 提交于 2019-12-11 19:28:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!