3 Replies - 903 Views - Last Post: 12 October 2012 - 10:59 AM Rate Topic: -----

#1 kr1s  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-October 12

Error in file location using Process.Start()

Posted 12 October 2012 - 08:56 AM

Hi,

I need some help with the below code, the below code what it does is calls another program to run as administrator. The location of the program that needs to run as administratoris in C:\. the problem is that when I run the program, the location location is reading as C:\\ instead of C:\ as can be seen by the attachment, I tried using @"C:\Softphone.exe" rather than "C:\\Softphone.exe" but still the same. Tried different locations and still the same. just before Process.Start(info) the location is fine as its reading the correct location, so it must be something from the process start. I'm running this on Windows XP using .NET Framework 4. Any idea what the issue could be.?

            ProcessStartInfo info = new ProcessStartInfo();
            SecureString theSecureString = new SecureString();

            string fileLocation = "C:\\Softphone.exe";

            info.FileName = fileLocation;
            info.RedirectStandardOutput = true;

            Console.WriteLine(info.FileName);

            info.UserName = "Administrator";

            theSecureString.AppendChar('*'); 
            theSecureString.AppendChar('*');
            theSecureString.AppendChar('*');
            theSecureString.AppendChar('*');
            theSecureString.AppendChar('*');
            theSecureString.AppendChar('*');
            theSecureString.AppendChar('*');
            theSecureString.AppendChar('*');
            info.Password = theSecureString;

            info.UseShellExecute = false;
            info.RedirectStandardError = true;
            info.RedirectStandardInput = true;
            info.RedirectStandardOutput = true;

            Console.WriteLine(info.FileName);
            Process.Start(info);

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Error in file location using Process.Start()

#2 CodeGrappler  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 41
  • View blog
  • Posts: 120
  • Joined: 29-November 10

Re: Error in file location using Process.Start()

Posted 12 October 2012 - 09:55 AM

When strings are viewed in one of Visual Studio's various debug windows it always escapes the string. So in your case "C:\\SoftPhone.exe" Is completely correct. What is your exact issue?
Was This Post Helpful? 0
  • +
  • -

#3 kr1s  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-October 12

Re: Error in file location using Process.Start()

Posted 12 October 2012 - 09:58 AM

I get an error

EventType clr20r3, P1 softphone.exe, P2 1.0.0.0, P3 5076b51e, P4 mscorlib, P5 4.0.0.0, P6 4ee9af8e, P7 3fda, P8 105, P9 system.io.directorynotfound, P10 NIL.
Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Error in file location using Process.Start()

Posted 12 October 2012 - 10:59 AM

Perhaps this will help:

http://blogs.msdn.co.../06/545090.aspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1