Tuesday 24 April 2018

Easiest way to grant "Log on as a service" to a Windows user from the command-line?


I want to script an install where a service needs to be run as a user. I want to be able to specify the user.


Creating the user is easy through the NET USER /ADD command.


Specifying the user for the service can also be done: the SC CONFIG command allows this.


Now the missing link: granting the user the "Log on as a service" privilege as a logon right (SeServiceLogonRight). Is there a command for this? Or a simple script for PowerShell?



Answer



The easiest way to do this from a command line is definitely using NTRights.exe from the Windows Server 2003 Resource Toolkit.


ntrights +r SeServiceLogonRight -u jeroen -m \\%COMPUTERNAME%

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...