vandervagos
vandervagos

Reputation: 113

C# after starting a process, the process exits immediately

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?

Upvotes: 2

Views: 5209

Answers (2)

Chris Dunaway
Chris Dunaway

Reputation: 11216

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

Upvotes: 6

Strillo
Strillo

Reputation: 2982

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

Upvotes: 0

Related Questions