473,657 Members | 2,447 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(s tartInfo);
}
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 2095
Ashok

Try the following code

Process mDOSProcess= new Process();
mDOSProcess.Sta rtInfo.FileName = @"cmd.exe";
mDOSProcess.Sta rtInfo.Argument s = your arguments;

//if you dont want to see the dos black screen
mDOSProcess.Sta rtInfo.CreateNo Window = true;
mDOSProcess.Sta rtInfo.UseShell Execute = false;

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

mDOSProcess.Sta rtInfo.Redirect StandardOutput = true;
mDOSProcess.Ena bleRaisingEvent s = true;
mDOSProcess.Exi ted += new EventHandler(Pr ocess_exited);

//now start the process
mDOSProcess.Sta rt();

//if you wanna wait for some reason to get completed for post processing
mpDOSProcess.Wa itForExit();
Shak.
"Ashok Subramanian" <as******@hotma il.com> wrote in message
news:46******** *************** **@posting.goog le.com...
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(s tartInfo);
}
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
2916
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 starting is that it has a welcome window first which gets displayed and then the real windows after a while,in other words it means that the process name is the same, but the handle I need to retrive is the one from the final window and not the...
4
14198
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 process = new Process(); process.StartInfo.FileName = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";
10
14417
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 user to gain the required rights for execution (the external process needs to create a mailbox in Exchange, so it needs to be run as an Exchange Full Administrator-powered user). For the moment, I have tries using the Start() static method of the...
7
3347
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 - When the first process is finished, it runs another Exe process (HHC.exe) The code is below:
12
2364
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 head. Natuarally it will not work. I expect it to use up all resources looping, which will not allow the process to complete. The process takes about 60 seconds, because the .bat file it is calling is rebuilding mulitple .NET solutions and projects...
15
1439
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 & "\mameversion.txt""") sw.Close()
3
11728
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 suggestions. 1) Check the file permissions for the document or drive. 2) Make sure there is sufficient free memory and disk space. 3) Open the file with the Text Recovery converter." The document that I want to display is on my PC and was created by...
2
4507
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 suggestions. 1) Check the file permissions for the document or drive. 2) Make sure there is sufficient free memory and disk space. 3) Open the file with the Text Recovery converter." The document that I want to display is on my PC and was created by...
0
1728
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 which wires up 4 events to trap Excel/Word Start/Stop events. The application works fine for Excel but Word behaves strangely. When I start an instance of Word I get the correct message displayed in the console. When I start a second instance of...
4
8830
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 windows service that converts MS Word Files into .PDF files and after that we want to zip the .PDF files. Our code: Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set...
0
8395
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...
1
8503
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
8605
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
7330
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6166
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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
4155
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
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.