Sign in to follow this  

supress the cmd window

This topic is 3583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, please help to how to hide cmd window while running a batch file for running an exe......... my batch file code shown as below: @ECHO OFF SET FileName= Start /WAIT .\FolderName\ABC.exe ECHO ON Exit while running this, C:\WINDOWS\System32\cmd.exe window shows.... but how to hide this window????

Share this post


Link to post
Share on other sites
Create a shortcut to the batch file, go to the shortcut properties and change "Run" to "Minimised", then run the shortcut.

Aside from that, you can't (Unless you have an app running in the background to catch the window and hide it or something). A batch file means "Open a command prompt window and run the following:", it doesn't make sense not to have a window.

Share this post


Link to post
Share on other sites
You don't need to exit the script explicitly, and 'echo' settings are per-command-window-instance, so there's no reason to turn it back on. Just have the 'start' as the last item, and the window should close immediately (while ABC.exe starts). That will help a little bit; but otherwise - like Evil Steve said.

Share this post


Link to post
Share on other sites
Hi,
Thanks for the reply.

But this will not work...
The situation is that i need to use this batch file inside a wisw installation exe application as a pre requiste so that this batch will trigger at first....

So keeping a short cut of batch file will not work inside this msi.....

Do u know any other way to hide the cmd.exe windom when a batch file is executed....

Thanks.............

Share this post


Link to post
Share on other sites
I assume you are telling the WISE installer maker to run the batch script?

Don't do that. Tell it to run the applications that the batch script currently runs.

Yes, 'set' and 'start' are applications. Or at least, they behave like applications; they should be usable in exactly the same way, via whatever interface you are given.

Share this post


Link to post
Share on other sites
One fullstop/period is usually sufficient at the end of a sentence [smile]

Is it not possible for you to get the msi to point direct directly at the executable, rather than indirectly through a batch file?

Unfortunately even with echos off a batch file will open command prompt, that's just how they work. No doubt it is possible to disable the window from showing but the technique, what it may involve, will likely be non-trivial and ugly.

Share this post


Link to post
Share on other sites
If you're launching that batch file via ShellExecute() you can simply pass SW_HIDE as the last parameter and it should make the window go away (although I've not tried it). It's documented at: http://msdn2.microsoft.com/en-us/library/bb762153(VS.85).aspx

What I'd suggest though is writing a small program that does exactly what the batch file does and running that. It's only a few lines of code.

Share this post


Link to post
Share on other sites

This topic is 3583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this