Computer shutdown from SGP

I go bush on New Moon with the imaging rig to a dark sky site and need to shutdown the computer because of battery power.

I had been using APT and it has an easy to use script eg #Shutdown, and shuts down the computer. I then have a USB switch that turns off the Dew Heaters, etc.

We all know automation means more sleep and knowing the mount is parked, the dew heaters are off and battery power is saved, helps.

I’m only new to SGP, but find the software great to use. It was a bit of a jump from APT, but I do like the auto focus, the CMOS camera Gain ability, PHD2 start up and the easy plate solve automation.

I thought a Planisphere link to populate RA and DEC could be useful, especially out bush away from internet coverage.
I manually populate the coordinates from Sky Safari, until I can save an image, then plate solve away.

Any clues welcome.

I have to run a command to shut down my PC as I’m working remotely.
I discovered psshutdown in the pstools.
Basically, in Win 7, you extract the psshutdown.cmd file and pop it in the windows folder. I call it with a little text file psshutdown.cmd /s /f /t 5 - which means shutdown, force apps to close and do it in 5 seconds. You will find examples on the web. You may be able to run a script at the end of the sequence in SGP and do the same.

Or you can run a script such as Buzz suggests using the Windows Scheduler set to run at a time that you specify.

There are free utilities that can do the same and run in the background, eg Airytec Switch Off - Shutdown your PC automatically or remotely from any computer or mobile phone.


Thanks for the reply.
I had a look at Airytec, not sure how to get that into a file?
I run win 10, so I guess there would be a similar version of psshutdown.
I’ll give that a try.

Had a go at psshutdown and it says, not compatible. (win 10)
Any other clues for script shutdown?

Hi Scott,

Win10 has a “shutdown” command:

Kind regards,

EDIT (as I think, my answer was incomplete):

  • Create a text file and give it a nice name like “KillMeNow.vbs” - the vbs extension is important.
  • Put these two lines into it:
Set myShell = WScript.CreateObject("WScript.Shell")
myShell.Run "C:\Windows\System32\shutdown.exe /s /f /t 0"

You now can set this script to be executed at the end of your sequence.

Be aware that the option to run a script runs the script before End of Sequence options AFAIK. Thus, you have to trigger the script outside of SGP.

You can place the script in Windows Scheduler to run at a set time or use the airey tec app at a set time.


Thanks for the tips.
I’m a little confused at the moment about this topic.
In Event Settings, Post Event Settings, there’s an option to Park Telescope etc.
There is an option to run a script from there. Am I to understand that I can add a file in here to
shutdown the apps and computer?

You can add a script where you state however AFAIK this script will execute before End of Sequence options.

So if you have the script switch off the pc, no End of Sequence options will have been triggered.

Yes, but not in the post event settings. There is also an option “run script at end of sequence” in the sequence settings:


Kind regards,

I understand it states that; however there was a thread on this some time ago (Power control at beginning and end of sequence - Feature Requests - Main Sequence Software) and a script will actually be executed prior to End of Sequence actions, and these End of Sequence actions will not commence unless and until the script completes.

AFAIUI, if your script powers down the PC, and End of Sequence options is park scope, warm up ccd, these actions will not happen because you have shutdown the PC.

Is there a way to shut down SGP at the end of the sequence? Nothing more than that.

If so then a separate application could sit there looking to see if SGP was still running, using the API to see if it was still responding maybe. Then when this application detects that SGP isn’t running it does any remaining close down and turns the PC off.

This has the advantage that it would close down if SGP crashes. It could make an observatory safe as well.

Or could the notification system be used? SGP sends an end of sequence notification and that is picked up and used to do the shut down.

That would be useful, some kind of watchdog monitor, which provides an indicator to an external application to make safe and shut down safely. Of course, if there are issues with ASCOM devices, another application may also have difficulty parking and shutting up shop.

For observatory power and equipment power control (including PC) I use the Lunatico Astronomia Dragonfly; both at my home observatory and remotely in Spain at a shared facility with my imaging partner, Gnomus.

As an example, at my home observatory, the Dragonfly is connected to the observatory network, its ascom driver controls my roof with magnetic sensors for open/close, its relays power on/off my equipment (including booting up, shutting down my mount). Sensors can monitor park position either with direct magnetic sensors on RA and Dec axis or by IR sensors reflecting off say the counterweight bar when in park position. These sensor state changes can trigger scripts. Lunatico provide a number of scripts and templates for adaptation.

In my case, I have added to the script for ShutterClose, inserting my equipment power off, mount shutdown and PC sleep. Within I have inserted double checks for park, sleep delays for ccd to warm up, mount to shut down etc. So when my roof closes, triggered by End of Sequence events (either at the completion of my sequence or due to a safety switch call), the action of closing triggers my observatory shutdown.

There are plenty of other ways of carrying out an observatory shutdown I’m sure.

There are also other lan or usb enabled relay devices that can be scripted - I have used devices made by Aviosys (eg IP switch 9258) previously with scripts for equipment control and observatory shutdown triggered by the Windows Scheduler at a set time.


Thanks for the tips on computer shutdown.
I gave Horia’s script a try in “run script at end of sequence” and it worked ok.
Checked "park telescope at sequence end"
Checked "disconnect all equipment at sequence end"
Added a few seconds on the script to be sure everything finished.
Computer then shut down. It’s a little crude, but much the same as APT.
This will be ok when camping out to save battery power and get some sleep.
It might be to much to ask, though, I wonder if there is a way to shut down other apps running
on the computer, from this script?