I'm trying to run a ps1 script that makes a "beep" alert when you lock or unlock your session on windows xp. I already got it and I'm trying to call that script through a VBS script. Problem is that if I execute the VBS manually, the power shell window appears and obviously, when i closed it, the script stop running. Here's my code:
This is the ps1:
$sysevent = [microsoft.win32.systemevents]
Register-ObjectEvent -InputObject $sysevent -EventName SessionSwitch -Action {[console]::Beep();Write-host ($args[1]).Reason}
And this is the VBS:
Set objShell = CreateObject("Wscript.Shell") objShell.Run("powershell.exe -noexit c:\beep.ps1")
Does anybody know how to prevent the power shell window and running the script in the background?