Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Why am I unable to start a process through c#

Posted on 2008-10-07
8
Medium Priority
?
850 Views
Last Modified: 2013-12-17
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

0
Comment
Question by:wbhltd
  • 4
  • 3
8 Comments
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 22657646
what was the specific error message?

Does your program require starting arguments?

Andrew
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 22657685
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

0
 
LVL 1

Author Comment

by:wbhltd
ID: 22657886
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?

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 22657929
What operating systems are on the two computers.  And if you could provide more information that would be helpful.
0
 
LVL 1

Author Comment

by:wbhltd
ID: 22657947
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?
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 22657998
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.

0
 
LVL 41

Expert Comment

by:graye
ID: 22658973
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 
0
 
LVL 1

Accepted Solution

by:
wbhltd earned 0 total points
ID: 22686433
Fixed it - all I needed to do add the following line
        p.StartInfo.WorkingDirectory = "c:\Folder"

Open in new window

0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question