Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0
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
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 21-Apr-10 5:06am
Edited 9-Jun-10 4:34am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You want to do something in the background while installation Smile | :)
 
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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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."
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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();
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

<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>
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 11 Jun 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100