#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\device_usbhd.ico #AutoIt3Wrapper_outfile=..\..\bin\copy2msc.exe #AutoIt3Wrapper_Res_Comment=http://www.hiddensoft.com/autoit3/compiled.html #AutoIt3Wrapper_Res_Description=AutoIt v3 Compiled Script #AutoIt3Wrapper_Res_Fileversion=3.1.1.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;========================================================================================== ; INCLUDES / OPTIONS #include #Include #include #include AutoItSetOption("MustDeclareVars", 0) If UBound(ProcessList(@ScriptName)) > 2 Then Exit opt("TrayMenuMode", 1) ;========================================================================================== ; APPLICATION VARIABLE DECLARATION $sAppName = "Copy2MSC" $iAppVerMajor = "2" $iAppVerMinor = "14" $sAppVerStage = "Release" $sAppAuthor = "Sean Shrum" $sAppDistrib = "http://www.shrum.net/sean/code/copy2msc" $sAppDonations = "http://www.shrum.net/cats.php?dir=/code^&body=./donations.shtml" $sAppDir = @UserProfileDir & "\Application Data\" & $sAppName & "\v." & $iAppVerMajor & "\" $sAppIni = $sAppDir & $sAppName & ".ini" $sAppTxt = $sAppDir & $sAppName & ".txt" $sAppLog = $sAppDir & $sAppName & ".log" $sAppTitle = $sAppName & " v." & $iAppVerMajor & "." & $iAppVerMinor $sSource = $sAppTxt ;========================================================================================== ; FIRST RUN SETUP If Not FileExists($sAppTxt) Then MsgBox(0, $sAppTitle, "It appears that this is the first time that " & $sAppName & " has been run under the current profile (" & @UserName & ")." & @CRLF & @CRLF & "Make sure your backup MSC device is currently connected, powered on, and has an assigned drive letter.") $sDestination = FileSelectFolder("Select or create a folder on your removable device that " & $sAppName & " will backup to", "", 7, "") If @error Then MsgBox(0, $sAppTitle, $sAppName & " can not continue until a destination location has been selected. Please restart " & $sAppName & " and define a removable destination device.") Exit EndIf IniWrite($sAppIni, "Settings", "Destination", StringStripWS($sDestination, 3)) IniWrite($sAppIni, "Settings", "Interactive", "1") IniWrite($sAppIni, "Settings", "Bubbletip", "1") FileCreateShortcut(@ScriptFullPath, @StartupDir & "\" & $sAppName & ".lnk") DirCreate($sAppDir) $pFile = FileOpen($sAppTxt, 1) $msg = "; Copy2MSC file list" & @CRLF $msg = $msg & ";" & @CRLF $msg = $msg & "; + Input complete paths to folder(s) you want copied in this file." & @CRLF $msg = $msg & "; + Subfolder inclusion (directory recursion) is automatic." & @CRLF $msg = $msg & "; + Each entry should be on its own seperate line." & @CRLF $msg = $msg & "; + Wildcards should be used such as:" & @CRLF $msg = $msg & "; + Examples:" & @CRLF $msg = $msg & "; [Monthly]" & @CRLF $msg = $msg & "; c:\*.au3" & @CRLF $msg = $msg & "; " & @CRLF $msg = $msg & "; [Weekly]" & @CRLF $msg = $msg & "; c:\music\*.mp3" & @CRLF $msg = $msg & "; " & @CRLF $msg = $msg & "; [Daily]" & @CRLF $msg = $msg & "; c:\documents and settings\shrum\my documents\*.*" & @CRLF $msg = $msg & "; " & @CRLF $msg = $msg & "; [Everytime]" & @CRLF $msg = $msg & "; d:\stuff\*.*" & @CRLF $msg = $msg & "; " & @CRLF $msg = $msg & ";======================================================================" $msg = $msg & @CRLF & @CRLF $msg = $msg & "[Monthly]" & @CRLF & @CRLF & @CRLF $msg = $msg & "[Weekly]" & @CRLF & @CRLF & @CRLF $msg = $msg & "[Daily]" & @CRLF & @CRLF & @CRLF $msg = $msg & "[Everytime]" & @CRLF & @CRLF & @CRLF FileWrite($pFile, $msg) FileClose($pFile) MsgBox(0, $sAppTitle, "I'll now open the file list in notepad so you can input the folders that you want to backup. Once you are done, save the file and close Notepad. " & $sAppName & " will automatically proceed once this is done.") Run('notepad "' & $sAppTxt & '"') ProcessWaitClose("notepad.exe") Else $sDestination = IniRead($sAppIni, "Settings", "Destination", "") EndIf Dim $aMonthly, $aWeekly, $aDaily, $aEverytime $iMonthlyFlag = 0 $iWeeklyFlag = 0 $iDailyFlag = 0 $sMonthly = IniRead($sAppIni, "Timestamp", "Monthly", "1970/03/24 00:00:01") $sWeekly = IniRead($sAppIni, "Timestamp", "Weekly", "1970/03/24 00:00:01") $sDaily = IniRead($sAppIni, "Timestamp", "Daily", "1970/03/24 00:00:01") $sEverytime = IniRead($sAppIni, "Timestamp", "Everytime", "1970/03/24 00:00:01") $iActive = 1 $iConnected = 0 $iBackupFlag = 0 $iSleep = 5 ;========================================================================================== ; MENU OPTIONS $mActive = TrayCreateItem("Active (" & StringLeft($sDestination, 2) & ")") TrayItemSetState($mActive, $TRAY_CHECKED) TrayCreateItem("") $mStartup = TrayCreateItem("Launch at startup") If FileExists(@StartupDir & "\" & $sAppName & ".lnk") Then TrayItemSetState($mStartup, $TRAY_CHECKED) $mInteractive = TrayCreateItem("Interactive") If IniRead($sAppIni, "Settings", "Interactive", "1") = "1" Then TrayItemSetState($mInteractive, $TRAY_CHECKED) if @OSVersion = "WIN_2000" then dim $mBubbletip $iBubbletip = 0 Else $mBubbletip = TrayCreateItem("Verbose") $iBubbletip = IniRead($sAppIni, "Settings", "Bubbletip", "1") EndIf If $iBubbletip = "1" Then TrayItemSetState($mBubbletip, $TRAY_CHECKED) TrayCreateItem("") $mDestinationSet = TrayCreateItem("Set destination...") $mDestinationView = TrayCreateItem("View destination...") TrayItemSetState($mDestinationView, 128) $mDestinationPurge = TrayCreateItem("Purge destination...") TrayItemSetState($mDestinationPurge, 128) TrayCreateItem("") $mMonthlyFlag = TrayCreateItem("Force monthly...") TrayItemSetState($mMonthlyFlag, 128) $mWeeklyFlag = TrayCreateItem("Force weekly...") TrayItemSetState($mWeeklyFlag, 128) $mDailyFlag = TrayCreateItem("Force daily...") TrayItemSetState($mDailyFlag, 128) $mEverytimeFlag = TrayCreateItem("Force everytime...") TrayItemSetState($mEverytimeFlag, 128) TrayCreateItem("") $mBefore = TrayCreateItem("Command before...") $mAfter = TrayCreateItem("Command after...") TrayCreateItem("") $mTimestampView = TrayCreateItem("View timestamps...") $mLogView = TrayCreateItem("View last backup log...") If Not FileExists($sAppLog) Then TrayItemSetState($mLogView, 128) $mSourceEdit = TrayCreateItem("Edit file list...") TrayItemSetState($mSourceEdit, 64+512) TrayCreateItem("") $mHomepage = TrayCreateItem("Homepage...") $mAbout = TrayCreateItem("About...") TrayCreateItem("") $mExit = TrayCreateItem("Exit") TraySetState() TraySetClick(16) ;========================================================================================== ; Splash bubble if $iBubbletip == "1" then TrayTip($sAppTitle, "Homepage: " & $sAppDistrib & @LF & "Like it? Contribute! See 'Homepage...' for details", $iSleep, 1) Else MsgBox(0, $sAppTitle, "Homepage: " & $sAppDistrib & @LF & "Like it? Contribute! See 'Homepage...' for details", 10) EndIf ; LOOP While 1 _menumonitor() If DriveStatus(StringLeft($sDestination, 3)) = "READY" Then if NOT FileExists($sDestination) then dircreate($sDestination) If $iConnected = 0 Then $iBackupFlag = 1 $iActive = 1 TrayItemSetState($mDestinationView, 64) TrayItemSetState($mDestinationPurge, 64) TrayItemSetState($mMonthlyFlag, 64) TrayItemSetState($mWeeklyFlag, 64) TrayItemSetState($mDailyFlag, 64) TrayItemSetState($mEverytimeFlag, 64) TrayItemSetState($mActive, $TRAY_CHECKED) TraySetToolTip ("Active (" & StringLeft($sDestination, 2) & ")") EndIf If $iActive = 1 Then $sTimestamp = _NowCalc() If _DateDiff('D', $sMonthly, $sTimestamp) >= 30 Then $iMonthlyFlag = 1 If _DateDiff('D', $sWeekly, $sTimestamp) >= 7 Then $iWeeklyFlag = 1 If _DateDiff('h', $sDaily, $sTimestamp) >= 24 Then $iDailyFlag = 1 If $iMonthlyFlag = 1 Or $iWeeklyFlag = 1 Or $iDailyFlag = 1 Then $iBackupFlag = 1 EndIf If $iBackupFlag > 0 Then $iActive = 1 TrayItemSetState($mActive, $TRAY_CHECKED) TraySetToolTip ("Active (" & StringLeft($sDestination, 2) & ")") If IniRead($sAppIni, "Settings", "Interactive", "1") = "1" Then If $iConnected = 0 Then If MsgBox(1, $sAppTitle, "Monitored drive " & StringLeft($sDestination, 2) & " connection has been detected." & @CRLF & "Backup will automatically start in 15 seconds." & @CRLF & @CRLF & _timestamps() & @CRLF & "Pressing 'Cancel' will abort backup until the device" & @CRLF & "is re-attached or a 'forced' backup is selected.", 15) = 2 Then $iActive = 0 Else If MsgBox(1, $sAppTitle, "A scheduled backup has been triggered." & @CRLF & "Backup will automatically start in 15 seconds:" & @CRLF & @CRLF & _timestamps() & @CRLF & "Pressing 'Cancel' will abort backup until the device" & @CRLF & "is re-attached or a 'forced' backup is selected.", 15) = 2 Then $iActive = 0 EndIf EndIf If $iActive = 1 Then trayTip($sAppTitle, "Backup process starting...", $iSleep, 17) TraySetToolTip ("Running: '" & IniRead($sAppIni, "Settings", "Before", "") & "'") if IniRead($sAppIni, "Settings", "Before", "") <> "" then RunWait(@ComSpec & " /c " & IniRead($sAppIni, "Settings", "Before", ""), StringLeft(IniRead($sAppIni, "Settings", "Destination", "NOTSET"), 2)) TraySetToolTip ("Backing up to " & StringLeft($sDestination, 2)) $aLog = _ArrayCreate ($sAppTitle & " - by: " & $sAppAuthor) _ArrayAdd($aLog, " ") _ArrayAdd($aLog, "Homepage: " & $sAppDistrib) _ArrayAdd($aLog, " ") _ArrayAdd($aLog, "Backup initiated: " & @YEAR & "." & @MDAY & "." & @MON & " @ " & @HOUR & ":" & @MIN & ":" & @SEC) _ArrayAdd($aLog, " ") _ArrayAdd($aLog, "Backing up to: " & $sDestination) _ArrayAdd($aLog, " ") _ArrayAdd($aLog, "Transaction key: (+)new, (=)same, (!)updated, (#)larger") $iFileCount = 0 $iFileCopy = 0 $iFileOverwrite = 0 _filelist() If $iMonthlyFlag Then _ArrayAdd($aLog, @CRLF & "===== < MONTHLY BACKUP > ======================================================") _backup($aMonthly) $sMonthly = $sTimestamp IniWrite($sAppIni, "Timestamp", "Monthly", $sTimestamp) $iMonthlyFlag = 0 EndIf If $iWeeklyFlag Then _ArrayAdd($aLog, @CRLF & "===== < WEEKLY BACKUP > =======================================================") _backup($aWeekly) $sWeekly = $sTimestamp IniWrite($sAppIni, "Timestamp", "Weekly", $sTimestamp) $iWeeklyFlag = 0 EndIf If $iDailyFlag Then _ArrayAdd($aLog, @CRLF & "===== < DAILY BACKUP > ========================================================") _backup($aDaily) $sDaily = $sTimestamp IniWrite($sAppIni, "Timestamp", "Daily", $sTimestamp) $iDailyFlag = 0 EndIf _ArrayAdd($aLog, @CRLF & "===== < EVERYTIME BACKUP > ====================================================") _backup($aEverytime) $sEverytime = $sTimestamp IniWrite($sAppIni, "Timestamp", "Everytime", $sTimestamp) $pFile = FileOpen($sAppLog, 2) For $i = 0 To UBound($aLog) - 1 FileWrite($pFile, $aLog[$i] & @CRLF) Next FileClose($pFile) filecopy($sAppLog, $sDestination & "\" & $sAppName & ".log", 1) TrayItemSetState($mLogView, 64) TraySetToolTip ("Running: '" & IniRead($sAppIni, "Settings", "After", "") & "'") if IniRead($sAppIni, "Settings", "After", "") <> "" then RunWait(@ComSpec & " /c " & IniRead($sAppIni, "Settings", "After", ""), StringLeft(IniRead($sAppIni, "Settings", "Destination", "NOTSET"), 2)) TrayTip($sAppTitle, "Backup process complete: " & @CRLF & $iFileCount & " evaluated / " & $iFileCopy & " copied / " & $iFileOverwrite & " updated", $iSleep, 17) If IniRead($sAppIni, "Settings", "Interactive", "0") = "1" Then If MsgBox(4 + 256, $sAppTitle, "Backup process complete." & @CRLF & @CRLF & " > Evaluated: " & $iFileCount & @CRLF & " > Copied: " & $iFileCopy & @CRLF & " > Updated: " & $iFileOverwrite & @CRLF & @CRLF & "Would you like to view the log file?") = 6 Then Run('notepad "' & $sAppLog & '"') EndIf TraySetToolTip ("Active (" & StringLeft($sDestination, 2) & ")") Sleep(5000) if $iBubbletip == "1" then TrayTip("", "", 0) Else TrayItemSetState($mActive, $TRAY_UNCHECKED) TraySetToolTip ("Inactive (User cancellation)") $sAction = "Backup cancelled by user." & @CRLF & "Re-attach device or use the force menus to restart." if $iBubbletip == "1" then TrayTip($sAppTitle, $sAction, $iSleep, 17) Else Msgbox(0, $sAppTitle, $sAction) endif EndIf EndIf $iConnected = 1 $iBackupFlag = 0 Else If $iConnected = 1 Then $iActive = 0 $iConnected = 0 $iBackupFlag = 0 TrayItemSetState($mDestinationView, 128) TrayItemSetState($mDestinationPurge, 128) TrayItemSetState($mMonthlyFlag, 128) TrayItemSetState($mWeeklyFlag, 128) TrayItemSetState($mDailyFlag, 128) TrayItemSetState($mEverytimeFlag, 128) TraySetToolTip ("Inactive (" & StringLeft($sDestination, 2) & " not present)") if $iBubbletip == "1" then TrayTip($sAppTitle, "Connection on " & StringLeft($sDestination, 2) & " severed", $iSleep, 1) EndIf EndIf WEnd ;========================================================================================== ; APPLICATION FUNCTIONS Func _backup($aFiles) If UBound($aFiles) == 1 Then Return For $h = 1 To $aFiles[0] _ArrayAdd($aLog, @CRLF & "> " & $aFiles[$h]) if $iBubbletip == "1" then TrayTip($sAppTitle, "Retrieving file list: " & @CRLF & $aFiles[$h], $iSleep, 17) TraySetToolTip ("Retrieving: " & $aFiles[$h]) $aSource = 0 $aSource = _FileSearch($aFiles[$h], 1) _ArraySort($aSource,0,1) If $aSource[0] > 0 Then For $i = 1 To $aSource[0] $iFileCount = $iFileCount + 1 if stringleft($aSource[$i], 2) = "\\" Then $sDrive = stringTrimLeft($aSource[$i], 2) $sDrive = stringtrimright($sDrive, stringlen($sDrive) - StringInStr($sDrive,"\")+1) $sFilename = StringRight($aSource[$i], StringLen($aSource[$i]) - StringInStr($aSource[$i], "\", 1, -1)) $sSubdirectory = stringTrimLeft($aSource[$i], stringlen($sDrive)+3) $sSubdirectory = stringtrimright($sSubdirectory, stringlen($sSubdirectory) - StringInStr($sSubdirectory,"\",1,-1)+1) Else $sDrive = StringLeft($aSource[$i],1) $sFilename = StringRight($aSource[$i], StringLen($aSource[$i]) - StringInStr($aSource[$i], "\", 1, -1)) $sSubdirectory = stringTrimLeft($aSource[$i], 3) $sSubdirectory = stringtrimright($sSubdirectory, stringlen($sSubdirectory) - StringInStr($sSubdirectory,"\",1,-1)+1) EndIf $sSubdirectory = "[" & $sDrive & "]\" & $sSubdirectory DirCreate($sDestination & "\" & $sSubdirectory) if $iBubbletip == "1" then TrayTip($sAppTitle, "Backing up " & $i & " of " & $aSource[0] & " files from:" & @CRLF & $sSource & "\" & $sSubdirectory, $iSleep, 17) TraySetToolTip ("Backing up: '" & $sFilename & "'") If FileExists($sDestination & "\" & $sSubdirectory & "\" & $sFilename) Then If FileGetTime($aSource[$i], 0, 1) > FileGetTime($sDestination & "\" & $sSubdirectory & "\" & $sFilename, 0, 1) Then $iFileOverwrite = $iFileOverwrite + 1 $iFileSizeMeg = _FileCopy($aSource[$i], $sDestination & "\" & $sSubdirectory & "\" & $sFilename) _ArrayAdd($aLog, " ! " & $sFilename) ElseIf FileGetSize($aSource[$i]) > FileGetSize($sDestination & "\" & $sSubdirectory & "\" & $sFilename) Then $iFileOverwrite = $iFileOverwrite + 1 $iFileSizeMeg = _FileCopy($aSource[$i], $sDestination & "\" & $sSubdirectory & "\" & $sFilename) _ArrayAdd($aLog, " # " & $sFilename) Else _ArrayAdd($aLog, " = " & $sFilename) EndIf Else $iFileCopy = $iFileCopy + 1 $iFileSizeMeg = _FileCopy($aSource[$i], $sDestination & "\" & $sSubdirectory & "\" & $sFilename) _ArrayAdd($aLog, " + " & $sFilename) EndIf if $iBubbletip == "1" then TrayTip("", "", 0) _menumonitor() Next EndIf Next EndFunc ;==>_backup Func _filelist() $aMonthly = _arraycreate(0) $aWeekly = _arraycreate(0) $aDaily = _arraycreate(0) $aEverytime = _arraycreate(0) $pFile = FileOpen($sSource, 0) While 1 $sLine = FileReadLine($pFile) If @error = -1 Then ExitLoop If StringLeft($sLine, 1) = ";" Then ContinueLoop If StringStripWS($sLine, 3) = "" Then ContinueLoop If StringLeft($sLine, 1) = "[" Then $sSection = StringMid($sLine, 2, StringLen($sLine) - 2) ContinueLoop EndIf Select Case $sSection == "Monthly" _ArrayAdd($aMonthly, $sLine) $aMonthly[0] = $aMonthly[0] + 1 Case $sSection == "Weekly" _ArrayAdd($aWeekly, $sLine) $aWeekly[0] = $aWeekly[0] + 1 Case $sSection == "Daily" _ArrayAdd($aDaily, $sLine) $aDaily[0] = $aDaily[0] + 1 Case $sSection == "Everytime" _ArrayAdd($aEverytime, $sLine) $aEverytime[0] = $aEverytime[0] + 1 EndSelect WEnd FileClose($pFile) EndFunc ;==>_filelist Func _menumonitor() $msg = TrayGetMsg() Select Case $msg = $TRAY_EVENT_PRIMARYDOWN Run('notepad "' & $sAppTxt & '"') Case $msg = $mMonthlyFlag $iBackupFlag = 1 $iMonthlyFlag = 1 If MsgBox(4, $sAppTitle, "You are about to force a MONTHLY backup." & @CRLF & @CRLF & "Would you like to also force a WEEKLY and DAILY backup as well?") = 6 Then $iWeeklyFlag = 1 $iDailyFlag = 1 EndIf Case $msg = $mWeeklyFlag $iBackupFlag = 1 $iWeeklyFlag = 1 If MsgBox(4, $sAppTitle, "You are about to force a WEEKLY backup." & @CRLF & @CRLF & "Would you like to also force a DAILY backup as well?") = 6 Then $iDailyFlag = 1 EndIf Case $msg = $mDailyFlag $iBackupFlag = 1 $iDailyFlag = 1 Case $msg = $mEverytimeFlag $iBackupFlag = 1 Case $msg = $mInteractive If IniRead($sAppIni, "Settings", "Interactive", "1") = "0" Then IniWrite($sAppIni, "Settings", "Interactive", "1") TrayItemSetState($mInteractive, $TRAY_CHECKED) Else IniWrite($sAppIni, "Settings", "Interactive", "0") TrayItemSetState($mInteractive, $TRAY_UNCHECKED) EndIf Case $msg = $mBubbletip If IniRead($sAppIni, "Settings", "Bubbletip", "1") = "0" Then IniWrite($sAppIni, "Settings", "Bubbletip", "1") TrayItemSetState($mBubbletip, $TRAY_CHECKED) $iBubbletip = "1" Else IniWrite($sAppIni, "Settings", "Bubbletip", "0") TrayItemSetState($mBubbletip, $TRAY_UNCHECKED) $iBubbletip = "0" EndIf Case $msg = $mStartup If FileExists(@StartupDir & "\" & $sAppName & ".lnk") Then FileDelete(@StartupDir & "\" & $sAppName & ".lnk") TrayItemSetState($mStartup, $TRAY_UNCHECKED) Else FileCreateShortcut(@ScriptFullPath, @StartupDir & "\" & $sAppName & ".lnk") TrayItemSetState($mStartup, $TRAY_CHECKED) EndIf Case $msg = $mSourceEdit Run('notepad "' & $sAppTxt & '"') Case $msg = $mDestinationSet $newdestination = FileSelectFolder("Select or create a folder on your removable device that " & $sAppName & " will backup to", "", 7, $sDestination) If Not @error Then $sDestination = $newdestination IniWrite($sAppIni, "Settings", "Destination", StringStripWS($sDestination, 3)) TrayItemSetText($mActive, "Active (" & StringLeft($sDestination, 2) & ")") Case $msg = $mDestinationView Run("explorer " & $sDestination) Case $msg = $mDestinationPurge If MsgBox(4 + 256, $sAppTitle, "Please confirm that you want to purge the destination folder:" & @CRLF & @CRLF & " > " & $sDestination & @CRLF & @CRLF & "All files and folders in this location will be deleted. Continue?") = 6 Then if $iBubbletip == "1" then TrayTip($sAppTitle, "Purging:" & @CRLF & $sDestination, $iSleep, 17) IniWrite($sAppIni, "Timestamp", "Purge", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC) FileRecycle($sDestination & "\*.*") DirCreate($sDestination) if $iBubbletip == "1" then TrayTip($sAppTitle, "Purging Complete:" & @CRLF & $sDestination, $iSleep, 17) If MsgBox(4, $sAppTitle, "Purging of " & $sDestination & " complete." & @CRLF & @CRLF & "It is recommended that you do a FULL (Monthly," & @CRLF & "Weekly, Daily, and Everytime) backup now." & @CRLF & @CRLF & "Do you want " & $sAppName & " to do this now?") = 6 Then $iMonthlyFlag = 1 $iWeeklyFlag = 1 $iDailyFlag = 1 $iActive = 1 TrayItemSetState($mActive, $TRAY_CHECKED) TraySetToolTip ("Active (" & StringLeft($sDestination, 2) & ")") EndIf EndIf Case $msg = $mActive If $iActive = 0 Then $iActive = 1 TrayItemSetState($mActive, $TRAY_CHECKED) TraySetToolTip ("Active (" & StringLeft($sDestination, 2) & ")") Else $iActive = 0 TrayItemSetState($mActive, $TRAY_UNCHECKED) TraySetToolTip ("Inactive (User disabled)") EndIf Case $msg = $mBefore $newbefore = InputBox($sAppTitle, "Define the command line (including arguments) to call BEFORE backup begins. Calls can be made to exe, com, pif, and bat files." & @CRLF & @CRLF & "Leave blank to do nothing.", IniRead($sAppIni, "Settings", "Before", "")) If Not @error Then IniWrite($sAppIni, "Settings", "Before", StringStripWS($newbefore,3)) Case $msg = $mAfter $newafter = InputBox($sAppTitle, "Define the command line (including arguments) to call AFTER backup completes. Calls can be made to exe, com, pif, and bat files." & @CRLF & @CRLF & "Leave blank to do nothing.", IniRead($sAppIni, "Settings", "After", "")) If Not @error Then IniWrite($sAppIni, "Settings", "After", StringStripWS($newafter,3)) Case $msg = $mTimestampView MsgBox(0, $sAppTitle, "Timestamps of the last run backups/purge:" & @CRLF & @CRLF & _timestamps()) Case $msg = $mLogView Run('notepad "' & $sAppLog & '"') Case $msg = $mHomepage RunWait(@ComSpec & " /c " & "start " & $sAppDistrib) Case $msg = $mAbout If MsgBox(4, "About " & $sAppName, " " & $sAppTitle & " by " & $sAppAuthor & @CRLF & @CRLF & " An automated file backup utility for MSC-compliant devices." & @CRLF & "Documentation, binaries, code, etc: " & $sAppDistrib & @CRLF & @CRLF & " If you find this utility useful, please show your support by donating $5." & @CRLF & @CRLF & " Would you like to visit the homepage page now?") = 6 Then RunWait(@ComSpec & " /c " & "start " & $sAppDistrib) EndIf Case $msg = $mExit Exit EndSelect EndFunc ;==>_menumonitor Func _FileCopy($sFrom, $sTo) $aTo = StringSplit($sTo, "\") $sPath = StringTrimRight($sTo, StringLen($aTo[$aTo[0]]) + 1) DirCreate($sPath) FileCopy($sFrom, $sTo, 1) Return FileGetSize($sFrom) / 1048576 EndFunc ;==>_FileCopy Func _FileSearch($szMask, $nOption) $szRoot = "" $hFile = 0 $szBuffer = "" $szReturn = "" $szPathList = "*" Dim $aNULL[1] If Not StringInStr($szMask, "\") Then $szRoot = @ScriptDir & "\" Else While StringInStr($szMask, "\") $szRoot = $szRoot & StringLeft($szMask, StringInStr($szMask, "\")) $szMask = StringTrimLeft($szMask, StringInStr($szMask, "\")) WEnd EndIf If $nOption = 0 Then _FileSearchUtil($szRoot, $szMask, $szReturn) Else While 1 $hFile = FileFindFirstFile($szRoot & "*.*") If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @error If $szBuffer <> "." And $szBuffer <> ".." And _ StringInStr(FileGetAttrib($szRoot & $szBuffer), "D") Then _ $szPathList = $szPathList & $szRoot & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) WEnd FileClose($hFile) EndIf _FileSearchUtil($szRoot, $szMask, $szReturn) If $szPathList == "*" Then ExitLoop $szPathList = StringTrimLeft($szPathList, 1) $szRoot = StringLeft($szPathList, StringInStr($szPathList, "*") - 1) & "\" $szPathList = StringTrimLeft($szPathList, StringInStr($szPathList, "*") - 1) WEnd EndIf If $szReturn = "" Then $aNULL[0] = 0 Return $aNULL Else Return StringSplit(StringTrimRight($szReturn, 1), "*") EndIf EndFunc ;==>_FileSearch Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN) $hFile = FileFindFirstFile($ROOT & $MASK) If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @error If $szBuffer <> "." And $szBuffer <> ".." And Not StringInStr(FileGetAttrib($ROOT & $szBuffer), "D") Then _ $RETURN = $RETURN & $ROOT & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) WEnd FileClose($hFile) EndIf EndFunc ;==>_FileSearchUtil Func _timestamps() $msg = "" $msg = $msg & " > Backup DESTINATION: " & @CRLF & " -" & $sDestination & @CRLF & @CRLF if IniRead($sAppIni, "Settings", "Before", "") <> "" then $msg = $msg & " > Command BEFORE: " & @CRLF & " -" & IniRead($sAppIni, "Settings", "Before", "") & @CRLF if IniRead($sAppIni, "Settings", "After", "") <> "" then $msg = $msg & " > Command AFTER: " & @CRLF & " -" & IniRead($sAppIni, "Settings", "After", "") & @CRLF $msg = $msg & @CRLF $msg = $msg & " > Last MONTHLY: " & @CRLF & " -" & IniRead($sAppIni, "Timestamp", "Monthly", "NEVER") & " = " & _DateDiff('D', IniRead($sAppIni, "Timestamp", "Monthly", "NEVER"), _NowCalc()) & " days ago" & @CRLF $msg = $msg & " > Last WEEKLY: " & @CRLF & " -" & IniRead($sAppIni, "Timestamp", "Weekly", "NEVER") & " = " & _DateDiff('D', IniRead($sAppIni, "Timestamp", "Weekly", "NEVER"), _NowCalc()) & " days ago" & @CRLF $msg = $msg & " > Last DAILY: " & @CRLF & " -" & IniRead($sAppIni, "Timestamp", "Daily", "NEVER") & " = " & _DateDiff('h', IniRead($sAppIni, "Timestamp", "Daily", "NEVER"), _NowCalc()) & " hours ago" & @CRLF $msg = $msg & " > Last EVERYTIME: " & @CRLF & " -" & IniRead($sAppIni, "Timestamp", "Everytime", "NEVER") & " = " & _DateDiff('n', IniRead($sAppIni, "Timestamp", "Everytime", "NEVER"), _NowCalc()) & " minutes ago" & @CRLF $msg = $msg & @CRLF & " > Last PURGE: " & @CRLF & " -" & IniRead($sAppIni, "Timestamp", "Purge", "NEVER") & " = " & _DateDiff('D', IniRead($sAppIni, "Timestamp", "Purge", "NEVER"), _NowCalc()) & " days ago" & @CRLF return $msg endfunc