How do I 'run as' 'Network Service'?

前端 未结 5 1231
悲哀的现实
悲哀的现实 2020-12-04 07:47

I am trying to run a process as another account. I have the command:

runas \"/user:WIN-CLR8YU96CL5\\network service\" \"abwsx1.exe\"

but th

5条回答
  •  情深已故
    2020-12-04 08:26

    You can only impersonate as service account from a Windows service typically, like this post mentions:

    The trick is to run your code as Local System and from there you can impersonate the service accounts by using the appropriate username with no password. One way to run your code as the Local System account is to create a command line shell by using the technique shown below (taken from this orginal post), and execute your assembly from there. Calling System.Diagnostics.Debugger.Break() in your code allows you to debug.

    To create a command-line shell that runs under the local system account, open a new command line window and enter:

    c:\sc create testsvc binpath= "cmd /K start" type= own type= interact
    

    followed by:

    c:\sc start testsvc
    

    A new command window should have opened up. In that window run your application.exe - you'll see that you're now running as the built-in System user account. After you've finished testing, you can delete the test service you created by entering:

    c:\sc delete testsvc
    

    If you try to do that in your own user context, then such attempts should fail.

提交回复
热议问题