Close cmd prompt from bat file
I find it rather annoying when I run a script at the command line and it closes my command window for me.
That's just me of course. I see your point, yet in this particular case the stated object was to force the command window to close. It turns out the exit was not required and was therefore not appropriate. I threw it in just to be sure, as I said.
I had failed to realize the fact that Win32 executable now run synchronously in command windows. In earlier Win versions, especially the Win9x varieties, they always ran asynchronously, unless you forced them to wait wth the Start utility. I don't know what OS introduced that twist. Either that or the Skype executable is actually a true command console application. Office Office Exchange Server. Not an IT pro? Internet Explorer TechCenter. Sign in. After the batch file has executed its last line of code it will stop running, unless the last line contained a GOTO command forcing it to re-execute some of its previous code.
When the batch file stops running it will return control to the command processor. If that command processor was started just for the purpose of executing the batch file, the command processor itself will stop running after completing batch file execution.
Active 2 months ago. Viewed k times. So far I've tried using the exit command within the batch file to close the cmd window I also have a shortcut on the desktop but it doesn't seem to work: tncserver. Improve this question. Jim McAdams 13 13 silver badges 29 29 bronze badges. Blitzcrank Blitzcrank 2 2 gold badges 10 10 silver badges 19 19 bronze badges. Add a comment. Active Oldest Votes.
It should close automatically, if it doesn't it means that it is stuck on the first command. As a work around you can try using start "" tncserver. Improve this answer. Bali C Bali C The "" is used to stop a problem with start , if the program you are running has spaces it will interpret the first string as the title for the app. The "" gives it a blank title so the rest will work as expected.
Your code is absolutely fine. It also looks better if I change the bat file icons for just those items to suit the context they are in too, but that's another matter, hiding the bat files in the subfolder and creating custom icon shortcuts to them in the root folder with the images called for the customisation also hidden. Or add a verification to confirm that you had the right cmd. Sometimes you can reference a Windows "shortcut" file to launch an application instead of using a ".
But it's not as flexible as bat files. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to automatically close cmd window after batch file execution? Ask Question. Asked 8 years, 11 months ago. Active 10 months ago. Viewed k times. Improve this question.
If the second line is a second command, try adding start before that as well. BernhardPoiss it is a separate command, NOT a parameter for putty.
0コメント