The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,822 other followers

Archive for April 28th, 2014

Easiest way to grant/query “Log on as a service” to a Windows user from the command-line? (my question on Super User)

Posted by jpluimers on 2014/04/28

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?

(I know only Local Service can do this out of the box, and no other accounts by default are, but I want to have control over the account and what other privileges that account has).

Edit: solved. Thanks Mathias R. Jessen.

Here is the solution, including a few comments.

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%

I changed the command-line a bit:

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

Note that

whoami /all

doesn’t show any change (not even after a reboot, it does not matter if you run it with or without UAC token).

secpol.msc

does show the change however, and does not require UAC (follow the tree to “Security Settings -> Local Policies -> User Rights Management -> Log on as a service” to see the users having the permission).

–jeroen

via: Easiest way to grant “Log on as a service” to a Windows user from the command-line? – Super User.

PS: Later I found out it is way easier to query the right:

accesschk.exe /accepteula -q -a SeServiceLogonRight

It will list the users having that right, for instance:

        IIS APPPOOL\Classic .NET AppPool
        NT SERVICE\ALL SERVICES
        VCS-CI\ContinuaCI>/pre>

Thanks twasbrillig for explaining that at as answer to powershell – How to view user privileges using windows cmd? – Stack Overflow

Posted in Batch-Files, CommandLine, Development, Power User, PowerShell, Scripting, Software Development, Windows, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Vista | Leave a Comment »

Building URLs to Old WordPress.com Stats (from a date in the past; via: Planet Botch)

Posted by jpluimers on 2014/04/28

Every once in a while you want to browse back to WordPress visitor stats from a while ago.

Well, you can hand-build your URLs like this:

Stats at the end of last year for the default WordPress.com blog:

The Old WordPress.com Stats – How to Access Them | Planet Botch post explains how to do this for non-default blogs as well.

–jeroen

via: Old WordPress.com Stats – How to Access Them | Planet Botch.

Posted in Power User, SocialMedia, WordPress | Leave a Comment »

 
%d bloggers like this: