I have a process running under the SYSTEM account (can't change this) that needs to execute a series of DOS-style commands. Specifically, it needs to run w32tm /resync which requires administrator privileges.
I have tried using the "runas" verb, which seems to take no effect even with ShellExecute set to true. I have also tried switching to a (known) user on the local machine, but I get the following exception: "The specified service does not exist as an installed service". If I run the program as the user I attempted to switch to, it works fine (admin is set in the app manifest).
I have also tried running each command as a separate process without using the batch file, and that does not seem to help either.
With everything I have tried so far, I either get the aforementioned exception or the call to w32tm /resync fails (indicative of not having admin rights).
Any ideas are appreciated!
Here is the code used to switch users:
procInfo.FileName = scriptPath;
procInfo.UserName = "admin";
procInfo.UseShellExecute = false;
procInfo.CreateNoWindow = true;
Process.Start(procInfo);