1

I'm having an issue with running slui.exe from a method in c#. I'm using the code:

ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Windows\System32\slui.exe"); Process p = new Process(); p.StartInfo = startInfo; p.Start(); p.WaitForExit();

but I keep getting a Win32Exception: 'The system cannot find the file specified'.

If I change the ProcessStartInfo to: (@"C:\Windows\System32\cmd.exe") it will launch just fine.

Is there something with running slui.exe in this context that is breaking?

I'm certain that the file is in the directory specified, so I'm stumped as to what may be going wrong here.

Any ideas how to call slui.exe from a c# method?

John Arlen
  • 6,539
  • 2
  • 33
  • 42
  • Have you actually gone to the directory itself and made absolutely sure that the file was there? – Abion47 May 15 '12 at 22:28
  • You can try `File.Exists(@"c:\Windows\System32\slui.exe")` to see if the system truly knows the file is there. – John Arlen May 15 '12 at 22:31
  • Well, **don't hardcode the path**! How do you know that their Windows folder is at `C:\Windows\`? And what happens when its a 64-bit installation? Or a 32-bit installation? – Cody Gray - on strike May 15 '12 at 22:36
  • Why are you trying to run that file anyway? Doesn't that exe have something to do with the Windows Activation? Are you performing acts that are less than savory? – Abion47 May 15 '12 at 23:04
  • Just my three cents years after the fact, but I'm currently also trying to run slui.exe and I'm far from trying to perform an act that's "less than savory". I'm trying to run the Windows Activation dialog in case I detect Windows isn't activated in our software installer. Trying to run slui.exe isn't necessarily shady. – Bas Dec 15 '15 at 06:30

1 Answers1

2

Slui.exe is only available as a 64-bit program on Windows x64. Your hard-coded path c:\windows\system32 will get re-directed to c:\windows\syswow64 when you run as a 32-bit process. And thus won't find the file.

Project + Properties, Compile tab, change the Platform target setting to "AnyCPU". Repeat for the Release configuration. And use Environment.GetFolderPath() to ensure it still works when Windows isn't installed to c:\windows.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • So, it works on my machine with VS2010 installed running in debug mode... but, when I compile and run it on a different machine, it will just exit immediately without opening up the activation window. I have a .manifest and have set the execution level to: "highestAvailable" ... so I don't think it's a permissions issue, and I changed the hard-coded path to the environment variable. Any ideas??? Thanks again for all the help!!! – user1360150 May 16 '12 at 14:43