run exe as system account

后端 未结 3 844
执念已碎
执念已碎 2021-01-14 05:05

I am trying to run my c# exe as an system account. How can I do that. I\'ve tried and

相关标签:
3条回答
  • 2021-01-14 05:41

    To the best of my knowledge you can not force your app to run as SYSTEM. Either your app must be a service and the service is setup to run as System or you must use a tool like PsExec to launch your executable as system.

    psexec.exe -i -s YourProgram.exe
    

    When using requestedExecutionlevel the only 3 valid options are

    • requireAdministrator - prompt for UAC always (even if the user is not an administrator).
    • asInvoker - never prompt for UAC.
    • highestAvailable - prompt for UAC if the user is a member of the Administrators group but do not prompt and run as a normal user if the user is not a member of the group.
    0 讨论(0)
  • 2021-01-14 05:43

    Hi I've found the solution. If you really want your exe to be run as system account you need to create a windows service and start it as a local system account. you would be able to see an exe is running at task manager along with a system account user. That is what I needed to know.

    0 讨论(0)
  • 2021-01-14 05:55

    It's not directly possible. There are hacky ways if you are an administrator (like getting the security token from an already running service or something), but I far from recommend using those.

    The point of the SYSTEM account is precisely that: that it's only run directly by the system.

    If you want an easy-hacky-way without third-party tools (like psexec), you could set up a ONEEVENT scheduled task (with schtasks, which is part of the OS), which can indeed run with the system account. This would still need two processes (although it could be the same exe with different command line parameters for the task and for setting it up), but it'd work.

    0 讨论(0)
提交回复
热议问题