I have below powershell script which fires refresh command every 1 min or so. It works perfectly fine when run manually from powershell. But I am having issues running it as a service.
while (1) {
$wsh = New-Object -ComObject WScript.Shell
$wsh.SendKeys('+{F15}')
Start-Sleep -seconds 59
}
I used nssm to convert it to a service and when I query it using Get-Service
command, I see it as running. However, I no longer see it's effects (system goes to sleep after 1 min as opposed to staying up which happens when I run this manually on powershell.)
Status Name DisplayName
------ ---- -----------
Running ps-refresh ps-refresh
Are there any extra steps required ?