I have a PowerShell script contained within a EXE which is installed as a Windows Service. When I try to use SCM to Start the service, it begins the process of starting the service but doesn't complete and SCM reports the service is not running. However, the EXE is started and is running properly in the background.
I do the following to install the service
try{New-Service -Name "Prob Service" -BinaryPathName "C:\AWCOProbe\Probe.exe" -DisplayName "Probe Service" -StartupType Automatic -Description "Probe"; WriteLogI "Installing Service"}catch{WriteLogI "Unable to Install Service"; $installerror = 1}
The Probe.exe
is just running a simple loop with no foreground window. The log file it updates is showing that the app is running in the background OK.
How can I get SCM to be able to start and stop the service properly?
SCM will hang around on this screen for a while and Task manager shows Probe.exe:
Then SCM will show this error and Taskmanager no longer shows Probe.exe but it is running under Windows Powershell: