V1.09 - added silent switch and simplification

This commit is contained in:
Michael H.G. Schmidt 2023-03-11 22:04:45 +01:00
parent 9098bc9538
commit 5dc9a6953b
2 changed files with 35 additions and 25 deletions

Binary file not shown.

View File

@ -29,9 +29,10 @@ EnableGraphicalConsole(0)
Dim filelist$(0)
Global VERSION$="V1.08"
Global VERSION$="V1.09"
Global updatesched = 0
Global dryrun = 0
Global silentmode = 0
Global hostname$ = GetEnvironmentVariable("COMPUTERNAME")
Global jobname$ = "snapcontrol"
Global month$ = FormatDate("%mm", Date())
@ -52,9 +53,10 @@ NewList DriveSnapshotVersion$()
DriveSnapshotVersion$() = "V1.48"
Procedure Usage()
PrintN ("usage: snapcontrol.exe [ /I | /V> | /D | /? ]")
PrintN ("usage: snapcontrol.exe [ /S | /I | /V> | /D | /? ]")
PrintN (" /S = silent mode (no user interaction!)")
PrintN (" /I = install/update scheduler job")
PrintN (" /V = show version")
PrintN (" /V = show version")
PrintN (" /D = dry run")
PrintN (" /? = help")
End 99
@ -73,6 +75,8 @@ ElseIf ( UCase(ProgramParameter(0)) = "/V" )
End 0
ElseIf ( UCase(ProgramParameter(0)) = "/D" )
dryrun = 1
ElseIf ( UCase(ProgramParameter(0)) = "/S" )
silentmode = 1
ElseIf ( ProgramParameter(0) = "/?" )
Usage()
EndIf
@ -338,31 +342,36 @@ If ( FtpBackup$ = "yes" )
TargetPath$ = "ftp://" + TargetUser$ + "@" + FtpServer$ + TargetPath$
EndIf
;
; ASK the user for permission to start ...
;
Result = MessageRequester("SnapControl",
"Start BACKUP now?" + Chr(13) +
"Targetpath => " + TargetPath$,
#PB_MessageRequester_YesNo | #PB_MessageRequester_Info)
If Result = #PB_MessageRequester_No
; SILENT mode.
; NO questions!
If ( silentmode = 0 )
;
; ASK the user for permission to start ...
;
Result = MessageRequester("SnapControl",
"backup ABORTED.",
#PB_MessageRequester_Ok | #PB_MessageRequester_Warning)
CloseConsole()
End 0
EndIf
"Start BACKUP now?" + Chr(13) +
"Targetpath => " + TargetPath$,
#PB_MessageRequester_YesNo | #PB_MessageRequester_Info)
;
; ASK the user for a shutdown ...
;
Result$ = InputRequester("SnapControl",
"SHUTDOWN system after backup?" + Chr(13) +
" (type 'yes' or 'no')", "no")
If Result = #PB_MessageRequester_No
Result = MessageRequester("SnapControl",
"backup ABORTED.",
#PB_MessageRequester_Ok | #PB_MessageRequester_Warning)
CloseConsole()
End 0
EndIf
If LCase(Result$) = "yes"
DoShutdown = 1
;
; ASK the user for a shutdown ...
;
Result$ = InputRequester("SnapControl",
"SHUTDOWN system after backup?" + Chr(13) +
" (type 'yes' or 'no')", "no")
If LCase(Result$) = "yes"
DoShutdown = 1
EndIf
EndIf
@ -542,7 +551,8 @@ EndProg(e)
; IDE Options = PureBasic 5.73 LTS (Windows - x64)
; ExecutableFormat = Console
; CursorPosition = 31
; CursorPosition = 374
; FirstLine = 333
; Folding = --
; EnableXP
; Executable = snapcontrol.exe