Jump to content

DMS-Reboot


Claus Peter

Recommended Posts

 

I wrote a small tool that restarts a computer on which the DVBViewer Media Server is running. But only if no recording is currently in progress or the DMS is not needed by a client. This also makes sense when the DMS computer is normally on standby. Even so, Windows loves to be restarted regularly. The program is called DMS-Reboot, has no GUI and does not require any installation. You can simply unzip the folder contained in the archive anywhere. The configuration is limited to adapting the URL to the DMS. To do this, the "DMS-Reboot.ini" file must be opened in a text editor and the standard path "localhost: 8089" changed accordingly. The: 8089 is the port used, which must be adapted if necessary. Usually you shouldn't have to change localhost unless you want to use this tool to restart a client system, depending on whether the DMS is currently in use. Then you have to replace localhost with the IP address of the DMS system. If you need a user name and a password to access the DMS, these must be entered in the URL in the form:

 

user:password@localhost:8089

 

where user and password must of course be replaced by the actual username and password. Now just save the .ini and the program is ready for use. If it is called up and a recording is currently in progress, it waits until the recording has ended. For this purpose, the status of the DMS is queried once a minute. As soon as this changes and no recording can be destroyed by the restart, the restart is made up for.

 

The whole thing only really makes sense if the tool is automatically called up regularly. You can use the Windows task scheduler for this. Here you create a simple task that simply executes the DMS-Reboot.exe file at the required rhythm. Further parameters are not necessary. The time at which the system should be restarted can of course be set individually. Personally, I have set 4:00 a.m. because I almost never watch or record anything at that time ...

 

The current version is V0.0.1.5

You can download it from where you can find all of our programs:

https://modellbahnblog.de/buddy-tools/downloads/

Edited by Claus Peter
Typo
Link to comment

I am looking for something similar. It shall query the DMS status. I want to put my Windows 10 x64 PC in standby (or to reboot) using dos batch file (command shutdown /h /f). The batch shall prevent standby (or reboot) if the DMS is executing scheduled timer or manual record or just serving to a remote client. Can you share your yay of checking the DMS status? Is there a simple way of doing this check/query via VBS or DOS?

Edited by dbotev
Link to comment

Hi.

The source code is included in the .zip file...

 

It's pretty simple. I'm downloading status2.html from the DMS API (as described in Wiki) and save it as XML (because it is an XML file) Now I have a look into this XML file if one of the counters in status are not "0" If all are "0" then I can reboot the system... If not, the tool waits for a minute and downloads a fresh status XML file and have a new look. This repeats until all counters are "0"... 

Link to comment

Hi.

Since there was a demand for a configuration tool, I just wrote one. The program is now offered as an installer package. After the completely normal installation, there is a new entry in the start menu that can be used to call up the config tool. Since it has to enter a task in the Windows task scheduler, it needs admin rights. If necessary, the corresponding data will be asked when the tool is started. Since Windows does not allow entries in the task planning by external programs without admin rights, this is unfortunately inevitable.

Zwischenablage-4.jpg.2b68b990393c4f8bfa123e96d06bbacc.jpg

 

The actual configuration is almost self-explanatory. you select the days of the week (one, several or all) on which the computer should be restarted. You also set the time. This must be entered in the 24 hour format. You can also make a few other settings for the task. You can delete an existing task (if it has already been created with the config tool) and add a new task. Deleting is only necessary if you want to switch off the automatic reboot completely. Otherwise an existing old task will be overwritten when a new task is created.

 

On the right you can then enter the access data for the DMS. URL and port must be filled in. The preset values fit directly with a standard installation of the DMS. For User and Password you enter a possible username and the corresponding password. If no password has been assigned, the two fields must absolutely be empty, so they must not contain "0" or "no username" or something like that.

 

Since the version of the Task Scheduler XML has increased from 1.2 to 1.4 since Win 10 2004, you also have to specify which Windows version you are using. Otherwise the entry into the task library will not work. With 8.1 or 7, the 1.2 also fits. So here you select “At most Windows 10 1909”.

 

You can set the interface in English and German. A restart is then necessary to use the new language.

 

Those who have already completed their configuration do not necessarily have to install the new version. However, I fixed a small bug in the actual program. So far it has been the case that the tool has always crashed if it could not load a valid status XML (usually if the URL or the access data are incorrect). Not that bad, because you don't notice anything. In such a case, the program is now terminated. The effect is the same (there is no restart), but it's cleaner that way ...

The download Link can be found in first posting.

Link to comment

I was able to re-use your code and to create my own standby algorithm (instead reboot) by changing the last 8 rows of the script. Thanks again for sharing it!

 

 

$state = _busy()

If $state = "1" Then

  Shutdown(32)

EndIf

 

 

I was observing Error-Event in the AutoIt script when the DMS is not running. I am not sure if the error occurs if you use exe instead the script itself.

 

Just stop the DMS service, run the "DMS-reboot.exe" and see what happens!

If Error occurs - it makes sense to check if the file status.xml File is empty (happens when the DMS is NOT running). This will prevent the Error- Event.

 

 

After this row “$file = FileRead(@ScriptDir & "\status.xml")” ...

...i just added this simple check: “If $file <> "" Then”

I do not know all the use cases, so it’s up to you if you add this to your script or not.

Edited by dbotev
Link to comment

Hi.

There indeed is a tiny little bug in the "old" version. I've added an even cleaner "If FileExists(@ScriptDir & "\status.xml") Then" into the new version... As long as you use the tool as intended it's not really an issue as you don't notice the "crash" at all... Now the tool does a clean exit instead of a "not so clean" exit in the older version.. The effect is completely the same = no reboot and termination of the tool..

 

Shutdown(xxx) has many options depending on the xxx You can reboot, shutdown, hibernate, standby logoff,...

 

Zitat

The shutdown code is a combination of the following values:
    $SD_LOGOFF (0) = Logoff
    $SD_SHUTDOWN (1) = Shutdown
    $SD_REBOOT (2) = Reboot
    $SD_FORCE (4) = Force
    $SD_POWERDOWN (8) = Power down
    $SD_FORCEHUNG (16) = Force if hung
    $SD_STANDBY (32) = Standby
    $SD_HIBERNATE (64) = Hibernate

You simply need to add the needed values. I use 18 here for Reboot (2) + Force if hung (16) = 18... This is used in other tools I've written, e.G. Media-Buddy where the user can select, what to do after the current job is done...

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...