473,624 Members | 2,288 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Diagnost ics.Process proc = new System.Diagnost ics.Process();
proc.EnableRais ingEvents=true;
proc.StartInfo. FileName="C:\Sh arp\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 9760
Mads,
Try this.
proc.StartInfo. WindowStyle = System.Diagnost ics.ProcessWind owStyle.Minimiz ed;

Also when you specify the file name try

proc.StartInfo. FileName="C:\\S harp\\Batfile.b at;

or

proc.StartInfo. FileName=@"C:\S harp\Batfile.ba t;

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.Diagnost ics.Process proc = new System.Diagnost ics.Process();
proc.EnableRais ingEvents=true;
proc.StartInfo. FileName="C:\Sh arp\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**********@d iscussions.micr osoft.com> skrev i en
meddelelse news:63******** *************** ***********@mic rosoft.com...
Mads,
Try this.
proc.StartInfo. WindowStyle =
System.Diagnost ics.ProcessWind owStyle.Minimiz ed;

Also when you specify the file name try

proc.StartInfo. FileName="C:\\S harp\\Batfile.b at;

or

proc.StartInfo. FileName=@"C:\S harp\Batfile.ba t;

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.Diagnost ics.Process proc = new System.Diagnost ics.Process();
proc.EnableRais ingEvents=true;
proc.StartInfo. FileName="C:\Sh arp\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
47488
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) 4) Once the copy is complete, the batch file opens the Access database again 5) EXIT should close out the cmd window but it does not execute that line
6
11214
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 programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS batch files, the batch files in turn run program installers (specifically windows update runtime .exe...
1
3170
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 programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS batch files, the batch files in turn run program installers (specifically windows update runtime .exe...
3
4456
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 cmd.exe with ASPNET as a user. But nothing happens. It can't execute the batch file. This is the code i am using to run the batch file:
1
3760
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 drop/add stored procedure definitions, alter table definitions & constraints, etc... and I would
1
24291
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 either.. Essentially it's just a wrapper for the Process class and a command interpreter. Warning, it only partly works. I had wanted to pass in (a) The name of the batch file (through "BatchFileName"), and
1
1320
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; proc.StartInfo.CreateNoWindow = false; proc.EnableRaisingEvents = false; proc.StartInfo.FileName = fileName;
4
3658
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 sql-server table. which means i need to build the string that will be used to call the batch file (set @var = 'callbatch.bat ' + @var1 + ' ' + @var2). then call the batch file using the xp_cmdshell command. each batch file runs about 4-5 hours. i don't...
14
12790
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 case it's a question, i want to popup a messageBox or something, and bring back to the batch file the result (Yes\No question). I know how to excute the batch file and get all the Standard output at the end, but i don't know who can i read it line by...
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8625
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.