I'm trying to automate the install of a
Windows Service for when I'm testing it locally. It is built in
.NET... I'd usually open the
Visual Studio Command Prompt as
Administrator and then type the
installutil command, I'm wanting to turn it into an "one-click" install.
So I've created the following batch script to make sure the most recent version is built, then elevate myself to do the actual service install (UserAdmin is my administrator account).
cd C:\Path\To\Solution echo Building Service msbuild WinService.sln /noconlog /nologo cd C:\Path\To\Solution\bin\Debug runas /user:UserAdmin "cmd /k C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil C:\Path\To\Solution\bin\Debug\WinService.exe"
However, installutil always gives me the following error:
An exception occurred during the Install phase. System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
I'm not sure if this is configuration issue, or if my batch script is wrong. But since I can't create a directory in the C:\Windows\System32\ folder that the
runas command prompt is started in, I suspect I'm not getting the permissions I was expecting. Is there a way I can check what user/permissions level I'm running at in the command prompt?
Note: I want to make this script as generic as possible. In the environment I'm working in everyone's administrator account is guaranteed to be 'UserAdmin'. The path to the solution will also be the same. This script will be added to SVN, so something like adding my particular password for the
UserAdmin account would not be acceptable.