Link to home
Start Free TrialLog in
Avatar of wbhltd
wbhltd

asked on

Why am I unable to start a process through c#

I am trying to start a process in a c# app.  I can start the process without any problems if I use "run", but when I start it with the follow code I get an error message.  

Could someone please help!!
ointerface = new Process();
 ointerface.StartInfo.FileName = @"c:\Folder\program.exe"; 
 ointerface.EnableRaisingEvents = true;
 ointerface.Start();

Open in new window

Avatar of REA_ANDREW
REA_ANDREW
Flag of United Kingdom of Great Britain and Northern Ireland image

what was the specific error message?

Does your program require starting arguments?

Andrew
The following works fine for me, so I am assuming you are not providing a starting argument.  What do you type to use the run command.  I would assume you use starting arguments there  
        [STAThread]
        static void Main(string[] args)
        {
 
            Process p = new Process();
            p.StartInfo.FileName = "notepad.exe";
            p.EnableRaisingEvents = true;
            p.Exited += new EventHandler(p_Exited);
            p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
            p.Start();
 
            Console.ReadLine();
        }
 
        static void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            Console.WriteLine(e.Data);
        }
 
        static void p_Exited(object sender, EventArgs e)
        {
            Console.WriteLine("Exited");
        }

Open in new window

Avatar of wbhltd
wbhltd

ASKER

I am not sure if that is the case, as I can get it to start if I try running it on a different computer. Might it be something to do with user/premisions?

What operating systems are on the two computers.  And if you could provide more information that would be helpful.
Avatar of wbhltd

ASKER

I am using windows XP on both.  The code executes fine on my PC, but on the PC I am using remotely it throws the error.  What other information should I provide?
Are the versions of the program the same on both machines that is being started?

What the exact error was and maybe the stack trace

any differences in the loading of the program

what access rights the program runs under.

What differences you can see from the outset from the two environments.

Remotely???     Do you mean that you're trying to start this process on a Remote PC?   If so, then you might consider using Windows Management Instrumentation (WMI)
http://msdn.microsoft.com/en-us/library/aa389388(VS.85).aspx 
ASKER CERTIFIED SOLUTION
Avatar of wbhltd
wbhltd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial