Run batch file minimized

M

Mads Westen

Hi,
I need to run a batch file wich I would like to run minimized.
The batchfile runs a exe file with some arguments, and deletes af file, and
remanes another.

How can I do that minimized? I know I can make a vbs file, and use the
following line to minimize:
Set WSHShell = Nothing

But can I do the same thing in C#?

Im running the bat file using:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=true;
proc.StartInfo.FileName="C:\Sharp\Batfile.bat;
proc.Start();

In fact, I could run the exe file, with arguments direct from C#?

Best regards
Mads
 
G

Guest

Mads,
Try this.
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;

Also when you specify the file name try

proc.StartInfo.FileName="C:\\Sharp\\Batfile.bat;

or

proc.StartInfo.FileName=@"C:\Sharp\Batfile.bat;

All the best,
Phil.
 
M

Mads Westen

Hi Phil,

Your suggestion works perfekt. I went with the .Hidden style at the end.
But your code let me the right way - thank you very much!

Best regards
Mads
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top