Over the years I've had some instances when ACP, MaxIm DL become unresponsive, thus preventing the #shutdownat (or #shutdown) directive to be executed. This left the dome open and sometimes the scope tracking. ACP is great when there is a script failure, because I employ ACP-ScriptFail.vbs. But that doesn't work when an app is unresponsive. Not a big deal if you know the weather is safe after dawn, and one can just attend to a manual shut down of the apps and the dome.
But I have a new problem - PIGEONS! Now that's it's Spring (in the northern hemisphere) these birds are looking for places to nest or roost, I don't know which, I'm not an ornithologist. And they've found my open dome in the morning (while I'm still sleeping) as an ideal location to try out - poop and all! No poop on the corrector plate, focuser, CCD camera or other system critical components - thank goodness! I did figure that Pigeons are not mobile after dusk and before dawn; a good thing.
My dome will park and close the shutter 8 minutes after loosing serial communication with the PC, so I thought that I should just shut down the PC whenever the ACP #shutdownat directive is complete.
So after cleaning up the Pigeon poop, I sat down and began to look into ways to kill the serial communication from the PC to the dome controller. I tried a brute force method of just invoking Windows shut down from Windows Task Scheduler, but that caused an ACP server error and a Windows BSOD. So I looked into a way to kill any apps using Windows taskkill to end one or more processes from a Windows batch file, and invoked by Windows Task Scheduler.
BTW, I know very little about scripting and Windows batch files, so chime in if you've got some tweaks. I suppose I could get fancy by testing in the batch file if an app is unresponsive (I think taskkill has that option) using something like:if <status of app is unresponsive) then taskkill etc.
In Task Scheduler, I have to adjust the scheduled time the batch file is invoked a few minutes after the time in the #shutdownat directive.
At any rate, I got what I was looking for to work using this batch file:
REM Ends tasks or processes
REM Order of ending each app can be important depending how your system is configured
REM Used SLEEP 1 <second> just to be sure each app ends before the next
REM
@ECHO OFF
c:\windows\system32\cmd.exe /c c:\windows\system32\TASKKILL.exe /F /IM FocusMax.exe
SLEEP 1
c:\windows\system32\cmd.exe /c c:\windows\system32\TASKKILL.exe /F /IM MaxIm_DL.exe
SLEEP 1
c:\windows\system32\cmd.exe /c c:\windows\system32\TASKKILL.exe /F /IM acp.exe