Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start a Console App as running under the System Windows user account?

I tried

var process = new Process
{
    StartInfo = new ProcessStartInfo
    {
        FileName = filename,
        UserName = "System",
        UseShellExecute = false,
    },
};

process.Start();

but it yields

Win32Exception was unhandled

Login failed: unknown user name or wrong password

I will have to use CreateProcessAsUser? How can I get the appropriate parameters to pass to that method?

like image 261
Jader Dias Avatar asked Jul 13 '11 13:07

Jader Dias


1 Answers

The System accounts password is maintained interally by Windows (I think) i.e. attempting to start a process as the System account by supplying credentials in this way is ultimately destined to failure.

I did however find a forum post that describes a neat trick that can be used to run processes under the system account by (ab)using windows services:

Tip: Run process in system account (sc.exe)

Alternatively the Windows Sysinternals tool PsExec appears to allow you to run a process under the System account by using the -s switch.

like image 120
Justin Avatar answered Sep 23 '22 21:09

Justin