I am trying to run my c# exe as an system account. How can I do that. I\'ve tried
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.