473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Run batch file minimized

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
Nov 17 '05 #1
2 9749
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.

"Mads Westen" wrote:
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

Nov 17 '05 #2
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

"Phil Williams" <Ph**********@discussions.microsoft.com> skrev i en
meddelelse news:63**********************************@microsof t.com...
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.

"Mads Westen" wrote:
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

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup)...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
3
by: emman_54 | last post by:
Hi every one, I am trying to run a batch file using my asp.net application. I am using the Process class to run the batch file. When I run my web application, In the task manager, i could see...
1
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that...
1
by: steve | last post by:
Hi all, Here's some work in progress that should allow you to run a batch file as a custom action in a VS deployment project. Yup I know you can use js or wsh, but the target may not have...
1
by: dheerajmarwaha | last post by:
Hi I am facing a problem in running a batch file. I am using the following code: Process proc = new Process(); proc.StartInfo.RedirectStandardOutput = false;...
4
ck9663
by: ck9663 | last post by:
hi guys this is a little challenging, at least for me...here goes... i have to run a DOS batch file from a server. with some parameters that i need to pass. these parameters can be found on a...
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.