added ForcedShutdown parameter

This commit is contained in:
Michael H.G. Schmidt 2023-03-19 12:29:35 +01:00
parent dffe98671b
commit fe2a4e0a9b
3 changed files with 28 additions and 14 deletions

Binary file not shown.

View File

@ -80,6 +80,9 @@ EjectMedia = yes
; should we ask for a shutdown after backup ? (yes/no) ; should we ask for a shutdown after backup ? (yes/no)
AskForShutdown = yes AskForShutdown = yes
; should we force a shutdown after the backup run?
; user will NOT be asked for consent! (useful for schedule mode "TIME" and silent mode)
ForcedShutdown = no
[LOGGING] [LOGGING]

View File

@ -7,7 +7,7 @@
; LICENSE : MIT License ; LICENSE : MIT License
; AUTHOR : Michael H.G. Schmidt ; AUTHOR : Michael H.G. Schmidt
; EMAIL : michael@schmidt2.de ; EMAIL : michael@schmidt2.de
; DATE : 20230312 ; DATE : 20230319
; ------------------------------------------------------------ ; ------------------------------------------------------------
; ;
; This tool creates an image backups of windows machines, ; This tool creates an image backups of windows machines,
@ -19,7 +19,6 @@
; Released under the MIT license. ; Released under the MIT license.
; ;
; ;
; INIT (set vars, read args, read inifile etc. pp.) ; INIT (set vars, read args, read inifile etc. pp.)
; ;
@ -29,7 +28,7 @@ EnableGraphicalConsole(0)
Dim filelist$(0) Dim filelist$(0)
Global VERSION$="V1.10" Global VERSION$="V1.11"
Global updatesched = 0 Global updatesched = 0
Global dryrun = 0 Global dryrun = 0
Global silentmode = 0 Global silentmode = 0
@ -39,7 +38,9 @@ Global month$ = FormatDate("%mm", Date())
Global day$ = FormatDate("%dd", Date()) Global day$ = FormatDate("%dd", Date())
Global DriveSnapshotVersionOk = 0 Global DriveSnapshotVersionOk = 0
Global DoShutdown = 0 Global DoShutdown = 0
Global Shutdowncommand$ = "shutdown /s /f"
; Timeout for shutodwn is 2 minutes ...
Global Shutdowncommand$ = "shutdown /s /t 120 /d p:0:0"
; valid versions for Drive Snapshot we support ... ; valid versions for Drive Snapshot we support ...
NewList DriveSnapshotVersion$() NewList DriveSnapshotVersion$()
@ -53,7 +54,7 @@ NewList DriveSnapshotVersion$()
DriveSnapshotVersion$() = "V1.48" DriveSnapshotVersion$() = "V1.48"
Procedure Usage() Procedure Usage()
PrintN ("usage: snapcontrol.exe [ /S | /I | /V> | /D | /? ]") PrintN ("usage: snapcontrol.exe [ /S | /I | /V | /D | /? ]")
PrintN (" /S = silent mode (no user interaction!)") PrintN (" /S = silent mode (no user interaction!)")
PrintN (" /I = install/update scheduler job") PrintN (" /I = install/update scheduler job")
PrintN (" /V = show version") PrintN (" /V = show version")
@ -114,6 +115,7 @@ Global EncryptPW$ = Trim(ReadPreferenceString("EncryptPW",""))
Global LimitIO$ = Trim(ReadPreferenceString("LimitIO","")) Global LimitIO$ = Trim(ReadPreferenceString("LimitIO",""))
Global EjectMedia$ = Trim(LCase(ReadPreferenceString("EjectMedia","yes"))) Global EjectMedia$ = Trim(LCase(ReadPreferenceString("EjectMedia","yes")))
Global AskForShutdown$ = Trim(LCase(ReadPreferenceString("AskForShutdown","no"))) Global AskForShutdown$ = Trim(LCase(ReadPreferenceString("AskForShutdown","no")))
Global ForcedShutdown$ = Trim(LCase(ReadPreferenceString("ForcedShutdown","no")))
PreferenceGroup("logging") PreferenceGroup("logging")
Global LogDir$ = Trim(ReadPreferenceString("LogDir","C:")) Global LogDir$ = Trim(ReadPreferenceString("LogDir","C:"))
@ -345,9 +347,7 @@ If ( FtpBackup$ = "yes" )
TargetPath$ = "ftp://" + TargetUser$ + "@" + FtpServer$ + TargetPath$ TargetPath$ = "ftp://" + TargetUser$ + "@" + FtpServer$ + TargetPath$
EndIf EndIf
; SILENT mode <> 0 => NO questions!
; SILENT mode.
; NO questions!
If ( silentmode = 0 ) If ( silentmode = 0 )
; ;
; ASK the user for permission to start ... ; ASK the user for permission to start ...
@ -368,13 +368,24 @@ If ( silentmode = 0 )
; ;
; ASK the user for a shutdown ... ; ASK the user for a shutdown ...
; ;
Result$ = InputRequester("SnapControl",
"SHUTDOWN system after backup?" + Chr(13) +
" (type 'yes' or 'no')", "no")
If LCase(Result$) = "yes" If ForcedShutdown$ <> "yes" And AskForShutdown$ = "yes"
Result$ = InputRequester("SnapControl",
"SHUTDOWN system after backup?" + Chr(13) +
" (type 'yes' or 'no')", "no")
If LCase(Result$) = "yes"
DoShutdown = 1
EndIf
EndIf
Else
; silent mode = true AND the admin has requested a forced shutdown ...
If ForcedShutdown$ = "yes"
DoShutdown = 1 DoShutdown = 1
EndIf EndIf
EndIf EndIf
@ -555,7 +566,7 @@ EndProg(e)
; IDE Options = PureBasic 5.73 LTS (Windows - x64) ; IDE Options = PureBasic 5.73 LTS (Windows - x64)
; ExecutableFormat = Console ; ExecutableFormat = Console
; CursorPosition = 29 ; CursorPosition = 20
; Folding = -- ; Folding = --
; EnableXP ; EnableXP
; Executable = snapcontrol.exe ; Executable = snapcontrol.exe