MountCMD

Part of the source code of MountCMD.
Figure 1: Part of the source code of MountCMD.
MountCMD is a software solution to park and shutdown a mount when the computer is shutdown by an UPS. It has been tested with my GM3000 in combination with Windows 10 on a NUC and an APC Back-UPS XS 1400U uninterruptible power supply. MountCMD is a small Java program that I created and which can be found on my server: http://www.dehilster.info/docs/MountCMD.zip

In order to use MountCMD the following should be arranged (it is presumed that Java is already installed on the pc):
  • Installation of a UPS that supplies the mount, the pc, and the network switch with emergency power.
  • Copy the MountCMD files to the pc;
  • Modification of the MountCMD.bat file;
  • Disabling the hibernation mode in Windows;
  • Enabling visibility of logoff scripts;
  • Setting that on logoff MountCMD should run.
Installation of a UPS
As the pc has to send the park and shutdown commands through the network to the mount it is essential that the ethernet connection between the pc and mount stays alive during power failure. If the UPS is connected to the pc using a powered USB-hub, then this hub should stay on during power failure as well. A connection to the internet is not required during a power failure.

Copy the MountCMD files to the pc
At the moment MountCMD has only been tested with the files located in a folder on the desktop. Copy the MountCMD.zip file the desktop and extract it there.


Line 4 of the batch file.
Figure 2: Line 4 of the batch file.
Modification of the MountCMD.bat file
At line 4 change the path in the command “cd c:\users…” to the directory where the MountCMD files are stored. Basically the section “InFINNity” should be replaced by the username that is used to login into the pc.

The current commandset is for 10Micron mounts, but are from the LX200 protocol and may need to be changed the match the commands of your mount.

Currently the park position (lines 16 and 18) is set with the scopes facing due east. Modify these lines to customise your parking position. The command :MA# slews the scopes to the position set in these two lines and stops it (i.e. it does not continue with tracking). I have chosen this orientation as it prevents birds to deposit their stuff on the objective when the observatory remains open.

Part of the commands is the IP-address (10.0.1.151) and port number (the 10Micron default 3492). These have to be changed where applicable.

The “timeout /t …” commands (with time in seconds) can be adjusted at will. The first timeout command is to allow the user to cancel the script when rebooting the pc without the need to shutdown the mount. The second timeout allows the mount to slew to the park position as without this timeout the slew will be stopped immediately or not even begin.

Disabling the hibernation mode in Windows

In order to be able to run a batch script on logoff, hibernation should be disabled:
  • First run the command prompt as administrator. In Windows 10, this can be done as follows:
    • hit the search glass on the taskbar
    • type "CMD" (without the quotes)
    • right mouse click on the CMD app and choose "Run as Administrator"
  • In the CMD window type "powercfg.exe /h off" (without the quotes and press enter). If an error occurs the CMD window was opened in a regular way, not as administrator.
  • Exit the CMD window by typing "exit" and pressing enter


  • Enabling visibility of logoff scripts

    The Windows gpedit.msc tool.
    Figure 3: The Windows gpedit.msc tool.
    This setting allows to cancel the MountCMD script when rebooting the pc while the mount should remain on. This setting is disabled as follows:
    • Press the windows flag and "R" simultaneously, type "gpedit.msc" and hit enter to start the Local Group Policy Editor
    • Goto User configuration -> Administrative Templates -> System -> Scripts
    • Doubleclick "Show commands when executing logoff scripts" and enable it
    During logoff the script will sometimes be visible as a large window in which the commands are shown, but more often this window is very small, almost only consisting of the minimise, maximise and close button (the cross). Regardless of its size, closing the window will immediately stop the execution of the MountCMD script. As the script starts with a timeout of 10 second there is ample time to avoid mount shutdown when only rebooting the pc.



    Set the MountCMD.bat file to be executed on shutdown

    • In the Local Group Policy Editor (see above) goto User configuration -> Windows settings -> Scripts Logon/Logoff -> logoff
    • Click the button "Add"
    • Click the button "Browse" and select the MountCMD.bat file
    • Click "OK" and close the Local Group Policy Editor
    Windows is now ready the shutdown the mount on logoff. MountCMD has been successfully tested several times. When power is restored the pc and mount will remain off. A logfile (MountCMD-log.txt) is created in the MountCMD folder:
    Connecting to mount to send “:Sa+00*00:00#”, current date/time is 26/05/2019 10:37:39
    Sending :Sa+00*00:00# to 10.0.1.151:3492
    Connecting to mount to send “:Sz+90*00:00#”, current date/time is 26/05/2019 10:37:39
    Sending :Sz+90*00:00# to 10.0.1.151:3492
    Connecting to mount to send “:MA#”, current date/time is 26/05/2019 10:37:39
    Sending :MA# to 10.0.1.151:3492
    Connecting to mount to send “:shutdown#”, current date/time is 26/05/2019 10:38:09
    Sending :shutdown# to 10.0.1.151:3492

    When the pc fails to connect to the mount MountCMD will attempt to reconnect up to ten times:
    Connecting to mount to send “:shutdown#”, current date/time is 26/05/2019 09:38:34
    Error connecting to 10.0.1.151:3492
    Reconnection attempt #1
    Error connecting to 10.0.1.151:3492

    Reconnection attempt #10
    Error connecting to 10.0.1.151:3492
    No mount found, message not sent…


    If you have any questions and/or remarks please let me know.


InFINNity Deck Astrophotography Astro-Software
Astronomical Twilight MountCMD MountMonitor ASCOM Generic UPS driver ASCOM SafetyMonitor Hub