Windows: run a program as local system 

Joined:
04/09/2007
Posts:
703

August 16, 2007 22:02:46    Last update: February 07, 2010 22:30:19
Today I tried to setup a ssh tunnel on Windows as a service. The command ran successfully in the command window, but failed every time I tried to start it as a service. Then I configured the service to run under my domain account and everything worked fine.

Apparently there's something special about running it under the local system account. I looked up the Runas command but it supported only running as another user, not as local system. I searched and found this article which solved my problem. The following captures the technique used.

Note that the spaces after binpath= and type= are required. The start service command at the end starts a cmd window using local system privileges.
E:\Documents and Settings\Adi>sc delete testsvc

[SC] DeleteService SUCCESS

E:\Documents and Settings\Adi>sc create testsvc binpath= "cmd /K start" type= own type= interact

[SC] CreateService SUCCESS

E:\Documents and Settings\Adi>sc start testsvc

[SC] StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion. 
Share |
| Comment  | Tags
 
Easy email testing with http://www.ximailstop.com