2

I'm trying to run a process from my app (C#, only for Win7), but on many PCs the process starts and closes immediately (as seen in task manager) and on other PCs it starts fine. This is the code I use:

ProcessStartInfo startInfo = new ProcessStartInfo(@"c:\windows\system32\slui.exe");
startInfo.UseShellExecute = false;
startInfo.Verb = "runas";
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
p.WaitForExit();

Am I missing something?

elixenide
  • 44,308
  • 16
  • 74
  • 100
vandervagos
  • 113
  • 3
  • 7
  • Have you tried reading from StandardError to see if there is a message? – Mark Byers Dec 19 '11 at 12:19
  • If you launch slui.exe from the command prompt do you have an error ? It propably stop immediately because slui.exe failed – Steven Muhr Dec 19 '11 at 12:20
  • possible duplicate of [Elevating process privilege programatically?](http://stackoverflow.com/questions/133379/elevating-process-privilege-programatically) – V4Vendetta Dec 19 '11 at 12:21
  • Why are you *not* using `ShellExecute`, yet setting the `Verb` property to `runas`? – Cody Gray - on strike Dec 19 '11 at 12:23
  • Do you see any error in the application event log of windows? – LMW-HH Dec 19 '11 at 12:28
  • I tried StandardError but there are no message. If i launch slui.exe from cmd, app runs correctly. The slui.exe gives an exit code 0. I read the Elevating process subject and i set shellExecute true and verb="runas" but there no difference. There is now error or exception – vandervagos Dec 19 '11 at 13:52

2 Answers2

6

I am not familiar with slui.exe, but could it be that you need to set the WorkingDirectory property of the ProcessStartInfo instance?

Chris Dunaway
  • 10,974
  • 4
  • 36
  • 48
0

It's a permission problem. You probably need to set the execution level as "requireAdministrator"

Strillo
  • 2,952
  • 13
  • 15