473,507 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Process.Start Help

Hello,

I am calling Process.Start from a C# code in the following way..where
startInfo is the object containing the process information.

try
{
Process installProc = null;
installProc = Process.Start(startInfo);
}
catch(Exception ex)
{
throw ex;
}

If for some reason I pass invalid arguments to the process I am
starting, I get a message saying "The application could not be
initialised". I never go to the catch block. Is there a way I can
catch this exception? Even if I pass wrong arguments, I need to catch
the exception to log it gracefully.

Thanks for the help,
Ashok
Nov 16 '05 #1
1 2087
Ashok

Try the following code

Process mDOSProcess= new Process();
mDOSProcess.StartInfo.FileName = @"cmd.exe";
mDOSProcess.StartInfo.Arguments = your arguments;

//if you dont want to see the dos black screen
mDOSProcess.StartInfo.CreateNoWindow = true;
mDOSProcess.StartInfo.UseShellExecute = false;

//if you want to make use of the output throw

mDOSProcess.StartInfo.RedirectStandardOutput = true;
mDOSProcess.EnableRaisingEvents = true;
mDOSProcess.Exited += new EventHandler(Process_exited);

//now start the process
mDOSProcess.Start();

//if you wanna wait for some reason to get completed for post processing
mpDOSProcess.WaitForExit();
Shak.
"Ashok Subramanian" <as******@hotmail.com> wrote in message
news:46*************************@posting.google.co m...
Hello,

I am calling Process.Start from a C# code in the following way..where
startInfo is the object containing the process information.

try
{
Process installProc = null;
installProc = Process.Start(startInfo);
}
catch(Exception ex)
{
throw ex;
}

If for some reason I pass invalid arguments to the process I am
starting, I get a message saying "The application could not be
initialised". I never go to the catch block. Is there a way I can
catch this exception? Even if I pass wrong arguments, I need to catch
the exception to log it gracefully.

Thanks for the help,
Ashok

Nov 16 '05 #2

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

Similar topics

12
2867
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
4
14182
by: Yiu | last post by:
upgent help i want to start IE explorer using C# i try many code such as below: ProcessStartInfo startInfo = new ProcessStartInfo("IEXPLORE.EXE"); Process.Start(startInfo); or Process...
10
14399
by: Sorin Dolha [MCSD .NET] | last post by:
I would like to start a process from C# code as another user. The C# code is executed as the ASPNET user because it relies in a Web Page class, and I would like that the process will run as another...
7
3334
by: Samantha | last post by:
Hello , I am developping a program for Win98 plateform, and I am stucking with a problem, hope you can help me. I have a program running 2 process : - One process running the Xcopy.exe -...
12
2347
by: Raymond Lewallen | last post by:
How to wait for a process to stop completion is my goal. Obviously, the looping while waiting for the HasExited property is not a solution.. but thats the best I can come up off the top of my...
15
1416
by: jcrouse | last post by:
Here is my code: Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\mameversion.bat") sw.WriteLine(lblMameExePath.Text & " -help >""" & Application.StartupPath &...
3
11705
by: Dean Slindee | last post by:
The code below is being used to launch WinWord.exe from a VB.NET program. Word launches, but displays this error message: "Word has experienced an error trying to open the file. Try these...
2
4501
by: Dean Slindee | last post by:
The code below is being used to launch WinWord.exe from a VB.NET program. Word launches, but displays this error message: "Word has experienced an error trying to open the file. Try these...
0
1716
by: =?Utf-8?B?Um9i?= | last post by:
I've a requirement to monitor when certain applications are started. I'm using WMI called from VS Stusio 2005 in VB to trap Excel and Word starting. I've written the following console application...
4
8792
by: Steven De Smet | last post by:
Hello, This is my first post. I searched on the internet for answers but I was unable to solve my problem. So I hope that you guy's can help me with my VB.NET problem I tried to create a...
0
7223
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
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7030
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...
0
7482
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...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
411
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...

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.