I have a Windows service built which is being installed by .NET 2.0's installutil /i
command. It installs the service as with the following account, with a password:
NT AUTHORITY\LocalService
When I run my service with net start <serviceName>
, I get
Error 5: Access Denied
To remove it I've had to open up services.msc
and from the Properties give the service
Logon As -> Local System Account
-> Allow Service to interact with desktop.
Can I put this whole “clicky” business into code which is either native .NET C# code or WMI or some other Batch script? I'll be using a batch script anyways so either is fine.