0

i use a program to see if my application is crashed and in this case i start it again. Let's call this application B while main application it's called A.

The main problem begin when the Application A is started from B.

Seems there are "Rights" problems to execute this code :

var processInfo = new ProcessStartInfo("myfile.bat")
                              {CreateNoWindow = true, UseShellExecute = false};
        processInfo.Verb = "runas";
        var process1 = Process.Start(processInfo);
        process1.WaitForExit();
        process1.Close();

I have this problem on Win Xp and 7. I tried to execute Application B with "Execute as Administrator" too without any result.

It's seems a Rights problem cause if i launch the program without Application B it works without problem.

user1107078
  • 455
  • 1
  • 7
  • 18

1 Answers1

2

Try to set UseShellExecute = true.

I don't know if a 'bat' files qualifies as executable.
And the docs says that only executables could be started when UseShellExecute is false.

Steve
  • 213,761
  • 22
  • 232
  • 286
  • But if i start by myself "double click" the program A it works without problem with this code. – user1107078 Mar 31 '12 at 08:55
  • +1. Batch files definitely aren't executables in that sense. @user1107078, double-clicking a file in Explorer works the same way as Process.Start with UseShellExecute set to true. – Harry Johnston Apr 01 '12 at 07:15