user1632018
user1632018

Reputation: 2555

Launching process from service under system account

I am having an issue launching a process from the system account. I just want to make it clear that I am not trying to run it under an interactive session, nor trying to impersonate any account. All I am trying to do is launch a process from the system account into the same session. The session in which the NTAUTHORITY\SYSTEM resides is 0 I believe.

I created a simple Windows Service that basically just uses Process.start to launch the executable. The Service is a system service.

I installed the service using SC as such:

sc create "MYSERVICE" binpath= "C:\Projects\MyService\MyService.exe" displayname= "My Awesome Service"

When I try to manually start the service I get a prompt that says "The ServiceName service on local computers started and then stopped. Some services stop Automatically if they are not in use by other services or programs."

Along with this the executable is never actually started. When monitoring it in processhacker I can see that the service does start, but the executable it attempts doesn't. Can anyone help me figure out why?

As I stated earlier my service is very basic, all it does is try and launch the executable when started:

  protected override void OnStart(string[] args)
    {
        Process.Start("svrexec.exe");
    }

    protected override void OnStop()
    {
    }

Upvotes: 1

Views: 1008

Answers (2)

Rubarb
Rubarb

Reputation: 95

Are you 100% sure it's not running? I tried and mine is running under the SYSTEM User Name check Show processes from all users in Task Manager

Upvotes: 0

EventHorizon
EventHorizon

Reputation: 2986

Did you specify full path to your executable? The working folder for the system user is %windir%\System32.

Try Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "svrexec.exe"), or set Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory

Upvotes: 0

Related Questions