1. get resource kit tools for 2003 (no 2008 at the moment of writing) just to have a copy of srvany.exe

2. ignore compatability warnings and install as is

3. create service using sc and binPath=”srvany.exe”

4. open regedit and create a string value /CreatedService/Parameters/Application

5. put Pathtopowershell.exe -ExecutionPlicy RemoteSigned -File PathToscript.ps1

start it

my example starting from 3:

c:>sc create PMHADaemon binPath= “C:Program Files (x86)Windows Resource Kits
Toolssrvany.exe” DisplayName= “PMHA Daemon”
c:>sc create Daemon binPath= "C:Program Files (x86)Windows Resource KitsToolssrvany.exe" DisplayName= "Daemon"
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesDaemon]
"Type"=dword:00000010
"Start"=dword:00000003
"ErrorControl"=dword:00000001
"DisplayName"="Daemon"
"ObjectName"="LocalSystem"
[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesDaemonParameters]
"Application"="C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -ExecutionPolicy RemoteSigned -File C:PMHAdaemon.ps1"

Post Navigation