Alrighty. I've got something working, but not sure how to implement it.
Have a look see at me code then there.
Code:
Break On
$nul=SetOption("Explicit","On")
$nul=SetOption("ASCII","On")
Dim $err
Dim $objWMI,$objEvent,$objHandle
Dim $strWQLQuery,$strType
Dim $fileOutput
$fileOutput = "c:\sd.log"
$err=0
$strWQLQuery = "SELECT * FROM Win32_ComputerShutdownEvent"
$objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!root\cimv2")
$objEvent = $objWMI.ExecNotificationQuery($strWQLQuery)
$nul=RedirectOutput($fileOutput)
While $err=0
? @Date + " " + @Time + " " + "Waiting for event..."
$objHandle=$objEvent.NextEvent
If $objHandle.Type = 0
$strType="Logoff"
? @Date + " " + @Time + " " + $strType + " Event Detected."
Else
$strType="Shutdown/Reboot"
? @Date + " " + @Time + " " + $strType + " Event Detected."
$err=1
ShutdownServices()
EndIf
Loop
? @Date + " " + @Time + " " + "Graceful shutdown."
Exit 0
Function ShutdownServices()
? @Date + " " + @Time + " " + "Stopping IISAdmin..."
Shell('cmd /c "Net Stop IISAdmin"')
? @Date + " " + @Time + " " + "Completed with EC:" + @Error + " SC:" +@Serror
EndFunction
Rather than call the shutdownservice fn, I'd like to directly let the other running kix script know that it's time to exit its loop. Problem is that I found no way to run the above asyncronously without a Sink_. And the Sink_ wouldn't work either b/c the vbscript would still need to inform the running kix script that it's time to quit.
I'd hate to scan a file or use a file as a semaphore, but I'm not seeing any other options... Any ideas out there?
_________________________
-Jim
...the sort of general malaise that only the genius possess and the insane lament.