8

I am trying to start a process as the LocalSystem account using this code

    ProcessStartInfo _startInfo = new ProcessStartInfo(commandName);
_startInfo.UseShellExecute = false;
_startInfo.UserName = @"NT AUTHORITY\SYSTEM";
_startInfo.CreateNoWindow = true;
_startInfo.Arguments = argument;
_startInfo.RedirectStandardOutput = true;

using (Process _p = Process.Start(_startInfo)) {
  _retVal = _p.StandardOutput.ReadToEnd();
  _p.WaitForExit();
}

But I am getting always the same error message saying "Logon failure: unknown user name or bad password". The user calling the function is a local admin and should be able to start a process with local system privilege. I also tried different combination but no luck.

I would appreciate any help. Thanks

auhorn
  • 465
  • 5
  • 10

2 Answers2

3

Unfortunately, I don't think you can do it so simply.

The underlying API that Process.Start() calls accepts a username and password, but since the SYSTEM user isn't a regular user and doesn't have a password I don't believe you can use it with this API.

You would have to use something like psexec (which you can, of course, call from Process.Start()).

EMP
  • 59,148
  • 53
  • 164
  • 220
0

I had some difficulties with this a while back. In the end managed it. What you're probably missing is some permission or other. See my previous question/answer.

Community
  • 1
  • 1
Matt Jacobsen
  • 5,814
  • 4
  • 35
  • 49