Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
See more:
Hi,

i want to hide cmd prompt while executing or running an .bat file..
i have an exe inside my .bat file..

Simply want to run .exe without showing the command prompt through bat file..

Here is my code
C++
StreamWriter sw = new StreamWriter(Program.DriveName + "\\" + txtName.Text + ".bat");
                     sw.WriteLine("START /d " + "\"" + "C:\\Program Files\\TestSetup" + "\"" + " StkView.exe % " + result);
                     sw.Close();



Regards,
Pawan
Posted
Updated 9-Jun-10 3:34am
v3

You want to do something in the background while installation :)

Google's first link gave me this:
If you create a shortcut to the batch file, you can set the properties of the shortcut to run the batch file in a minimized window instead of using the default setting of "Normal window".
If you want it completely hidden, then try using scripting:
Create a Process in a Hidden Window[^]
Modify the sample script to run something like "cmd.exe /c abc.bat" instead (with abc.bat replaced with the actual filename).


Here are few more links:
http://www.geekstogo.com/forum/Hide-command-prompt-windows-t56092.html[^]
http://stackoverflow.com/questions/1096591/how-to-hide-cmd-window-while-running-a-batch-file[^]

==============

From JSOP: You can lead a horse to water, but you can't make him drink.
 
Share this answer
 
v2
hi
issue is not solved yet.

===========

From JSOP: Well, then we can magically divine what must be wrong, despite your inability to provide the code you're using. Waitaminit... It's coming to me... The answer is... "You're a retard."
 
Share this answer
 
v2
You can create a process and set the ProcessWindowStyle property to Hidden:

string path = Program.DriveName + "\\" + txtName.Text + ".bat";
StreamWriter sw = new StreamWriter(path);
sw.WriteLine("START /d " + "\"" + "C:\\Program Files\\TestSetup" + "\"" + " StkView.exe % " + result);
sw.Close();
Process proc = new Process();
proc.StartInfo.FileName = path;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();


Also you can execute the command without writing it into a bat file by passing it as an argument to the cmd file:

Process proc = new Process();
proc.StartInfo.FileName = "cmd";
proc.StartInfo.Arguments = "/cSTART /d " + "\"" + "C:\\Program Files\\TestSetup" + "\"" + " StkView.exe % " + result;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
 
Share this answer
 
v2
<pre lang="C++">Hi

i want to hide the commandprompt window, when i click on any bat file from a physical location.for exa: Z:\sample1.bat, how to do it while creating bat file through the code window?

Have any idea, please let me know
Regards,
Pawan.</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900