Configuring a service to be started under Local Service account from command line

To be clear, the proper command is:

SC CONFIG MYSERVICENAMEHERE obj="NT AUTHORITY\LocalService" password= ""

Regarding previous comment, be aware that Local System and Local Service is not the same account. Local Service has much less rights.


@Amir's answer was the closest, but spaces are needed after the equal signs. If you view the help for SC.EXE, you'll see:

NOTE: The option name includes the equal sign.
      A space is required between the equal sign and the value.

So to get this to work under the real Local Service account on Windows 2012 R2, the following worked:

SC.EXE CREATE TheServiceName start= auto binPath= "C:\path\to\TheService.exe" obj= "NT AUTHORITY\LocalService" password= ""

When I tried...

obj= "\Local Service"

...it didn't get set to run under the real Local Service account.