Exit Posted June 4, 2019 Share Posted June 4, 2019 (edited) Have you ever shut down the computer while still performing a backup? If not, then ignore this post. Otherwise, this program may be helpful. It is registered in the startup folder after a query and then runs with every system start and ends only with system shutdown. Whenever a backup activity begins or ends, a message is generated. This prevents the computer from being accidentally turned off while a backup is still active. expandcollapse popup; BackupDetector.exe Backup attention popup. ;============================================================================================================== ; Programm Name: BackupDetector.exe ; Description: Monitoring backup activities. ; Whenever a backup activity starts or ends, a message is generated. ; This eliminates the possibility of accidentally turning off the computer while a backup is still active. ; Syntax: BackupDetector.exe (no Parameters) ; Return Value(s): None. It's a never ending programm. ; Author: Exit ( http://www.autoitscript.com/forum/user/45639-exit ) ; SourceCode: http://www.autoitscript.com/forum/index.php?showtopic=199161 Version: 2019.06.21 ; COPYLEFT: © 2019 Freeware by "Exit" ; ALL WRONGS RESERVED ;============================================================================================================== #pragma compile(AutoItExecuteAllowed, True) #AutoIt3Wrapper_Res_SaveSource=y #NoTrayIcon If Not @Compiled Then Opt("TrayIconHide", 0) Opt("ExpandVarStrings", 1) #include <_SingleScript.au3> ; http://www.autoitscript.com/forum/index.php?showtopic=178681 _SingleScript() ; Close all running scripts with the same name $l = (StringRight(@OSLang, 2) = "07") ? 0 : 1 ; German=0 other=1 $sScriptShortcut = @AppDataDir & "\Microsoft\Windows\Start Menu\Programs\Startup\" & StringTrimRight(@ScriptName, 3) & "lnk" If @Compiled Then If Not FileExists($sScriptShortcut) Then $rc = MsgBox(4 + 32 + 256 + 262144, Default, $l ? _ "Should the program run at every system start?" : _ "Soll das Programm bei jedem Systemstart ausgeführt werden?") If $rc = 6 Then $rc = FileCreateShortcut(@ScriptFullPath, $sScriptShortcut) MsgBox(64 + 262144, Default, ($rc ? "" : ("--> " & ($l ? "NO" : "KEINE") & " <-- ")) & _ ($l ? "Shortcut created in the startup folder." : "Verknüpfung im Startordner erstellt.")) EndIf EndIf EndIf $bMessagebox = False $hPid = 0 While Sleep(5000) If ProcessExists("vssvc.exe") Then ; is Volume Shadow Copy running? If $bMessagebox = False Then If $hPid Then ProcessClose($hPid) $sText = $l ? "The backup is now running. @HOUR@:@MIN@:@SEC@@LF@" & _ "Please do not turn off the computer." & @LF & _ "When the backup is finished, a new message appears." : _ "Die Sicherung läuft jetzt. @HOUR@:@MIN@:@SEC@@LF@" & _ "Den Computer bitte nicht ausschalten." & @LF & _ "Wenn die Sicherung beendet ist, erscheint eine neue Meldung." $sCommand = '$rc = MsgBox(64+262144,@ScriptName & " on " & @Computername,"' & $sText & '") + Sleep(2147483647)' ; Retain PID due to sleep $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' $hPid = ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand) $bMessagebox = True EndIf Else If $bMessagebox = True Then If $hPid Then ProcessClose($hPid) $sText = $l ? "The backup is done. @HOUR@:@MIN@:@SEC@@LF@" & _ "The computer can (but does not have to) be turned off." & @LF & _ "Thank you for your patience, now you can press 'OK'." : _ "Die Sicherung ist fertig. @HOUR@:@MIN@:@SEC@@LF@" & _ "Der Computer kann (aber muss nicht) ausgeschaltet werden." & @LF & _ "Vielen Dank für ihre Geduld. Nun können Sie 'OK' drücken." $sCommand = '$rc = MsgBox(64+262144,@ScriptName & " on " & @Computername,"' & $sText & '") + Sleep(2147483647)' ; Retain PID due to sleep $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' $hPid = ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand) $bMessagebox = False EndIf EndIf WEnd ; End of BackupDetector script Edited June 21, 2019 by Exit altered language handling and added @computername to messagebox Earthshine 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
moosjuice Posted June 12, 2019 Share Posted June 12, 2019 I haven't made one yet, but making this a service would be worth looking into. It seems to be a lot of trouble but you made a program that can use it. Link to comment Share on other sites More sharing options...
Exit Posted June 12, 2019 Author Share Posted June 12, 2019 I see no reason to run this program as a service. The program can be registered in the startup folder and then runs automatically when the system is started. Since no icon is displayed in the taskbar and system tray, it silently runs in the background. So why run as a service? App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
moosjuice Posted June 13, 2019 Share Posted June 13, 2019 (edited) The reason I listed it is because there are only upsides to a long running program being a service. So in describing it, you described a slight downside. 1. Clutter. If you have apps that start on startup you will have to look all the way in the startup folder for this program rather than msconfig, as well as it won't take up room in the task manager. The 2nd point is only true if the user has no login. But to be fair this is only slightly your fault if the backup software needs to be logged in to run. However there could be backup software could be created to these specs in the future. 2. The program can be started without being logged in if there is a hard reset rather the soft reset you describe, e.g. a power failure. 3. Service manager can automatically restart the program if it crashes without an external script. Edited June 13, 2019 by moosjuice Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now