daily pastebin goal
34%
SHARE
TWEET

Bootless Star [DeLorean - v5.2]

Siberian_Tiger Jul 12th, 2013 (edited) 170 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. REM Created by Nicholas "Tiger" Gautier
  2. REM Contact: SibTiger_And_Life@Hotmail.com
  3. REM Website: http://tigersfiles.webs.com/
  4. REM Details: This program allows the user to backup their personalized data that is stored in their home directory.
  5. REM Prerequisites:
  6. REM     Bootless Star 1.5 or later
  7. REM         http://forum.drdteam.org/viewtopic.php?p=53914#p53914
  8. REM     7Zip 9.20
  9. REM         http://7-zip.org/
  10. REM ==========================================
  11.  
  12.  
  13. REM Start at Main
  14. GOTO :Main
  15.  
  16.  
  17.  
  18.  
  19. REM =====================================================================
  20. REM Terms of Agreement (AKA Legal Crap)
  21. REM ----------------------------
  22. REM Self explanatory....
  23. REM =====================================================================
  24.  
  25.  
  26. REM I have removed the code and the terms of agreement wording from this section.  I am sure that it is not accurate and I am not a lawyer, but instead I am just a creator.  I have created this program for several reasons:
  27. REM    A} To make some tedious tasks - less tedious and expeditious
  28. REM    B} To help others get the job[s] finished
  29. REM    C} Allow everyone to use this program and even further expand it for their reasons or purposes
  30. REM
  31. REM In exchange all that I ask for those wanting to create a script or module [I can't force anyone to follow these]:
  32. REM    A} When you create a module or script that is designed for this program, do NOT mislead the user.  Thus, do not cause intentional harm to the user our their system.
  33. REM    B} Modules and scripts source code should always be available.  With batch, that shouldn't be much of a problem as the scripts are already readable.
  34. REM
  35. REM If someone wishes to take this entire program and up[date|grade] it or change it for whatever reasons, feel free to-do so.  Do not, however, charge users (currency wise) for using and retrieving the program.  I [the creator of this program] would like _some_ credit for the main work, the meaning of _some_ can be a simple comment within the program.
  36.  
  37.  
  38.  
  39.  
  40. REM # =============================================================================================
  41. REM # Documentation: The spine of the program; the main is the general flow of the program but not the center of the program.  When this module starts, main will always be the function to execute.  Not only is this easier on the eyes, but this will help the programmer or user to not 'get lost' when reading the code.
  42. REM # =============================================================================================
  43. :Main
  44. REM Clear the terminal buffer
  45. CALL :ClearBuffer
  46.  
  47. REM Setup the identifiers as needed for this program
  48. CALL :Initialization_Driver Load
  49.  
  50. REM Check and manage any protocols necessary within the prerequisite manager.
  51. CALL :Prerequisite_Driver || SET FatalExit=1
  52.  
  53. REM Open the main menu and drive the program from there.
  54. IF %FatalExit% EQU 0 CALL :MainMenu
  55.  
  56. REM Set the termination process.
  57. CALL :Terminate_MainExit
  58.  
  59. REM terminate the script with the exitcode obtained from the Termination process.
  60. EXIT /B %scriptExitCode%
  61.  
  62.  
  63.  
  64.  
  65. REM =====================================================================
  66. REM Prerequisites Check
  67. REM ----------------------------
  68. REM Check if wither or not the user meets all of the necessary prerequisites.  If the user is missing the necessary prerequisites - then the users session will ultimately terminate.  Other prerequisites, however, such as local directories can be created and setup for the program's use exclusively.
  69. REM =====================================================================
  70.  
  71.  
  72. REM # =============================================================================================
  73. REM # Documentation: This function will run through the prerequisite driver and make sure that this program's dependencies are meet.
  74. REM # =============================================================================================
  75. :Prerequisite_Driver
  76. REM Does the Local Directories exists?
  77. CALL :Prerequisites_LocalDirectory
  78. EXIT /B %ERRORLEVEL%
  79.  
  80.  
  81.  
  82. REM # =============================================================================================
  83. REM # Documentation: If the local directories where not created, then display a warning message.
  84. REM # =============================================================================================
  85. :Prerequisites_LocalDirectory_CheckErr
  86. ECHO !ERR_CRIT!: Could not create dependable directories!
  87. ECHO              %LocalDirectory.MainRoot%
  88. ECHO              %LocalDirectory.Temp%
  89. ECHO              %LocalDirectory.UserConfig%
  90. ECHO              %LocalDirectory.Backup%
  91. ECHO              %LocalDirectory.Restore%
  92. ECHO              %LocalDirectory.Logs%
  93. PAUSE
  94. EXIT /B 1
  95.  
  96.  
  97.  
  98. REM # =============================================================================================
  99. REM # Documentation: This function will check to make sure if the local directories exists within the filesystem, if - however they do not exist, then the directories will be created.  This local directories are crucial for this program as they are used for storing temporary data and output data.
  100. REM # =============================================================================================
  101. :Prerequisites_LocalDirectory
  102. IF NOT EXIST "%LocalDirectory.MainRoot%" (
  103.     MKDIR "%LocalDirectory.MainRoot%" || GOTO :Prerequisites_LocalDirectory_CheckErr
  104. )
  105. IF NOT EXIST "%LocalDirectory.Temp%" (
  106.     MKDIR "%LocalDirectory.Temp%" || GOTO :Prerequisites_LocalDirectory_CheckErr
  107. )
  108. IF NOT EXIST "%LocalDirectory.UserConfig%" (
  109.     MKDIR "%LocalDirectory.UserConfig%" || GOTO :Prerequisites_LocalDirectory_CheckErr
  110. )
  111. IF NOT EXIST "%LocalDirectory.Backup%" (
  112.     MKDIR "%LocalDirectory.Backup%" || GOTO :Prerequisites_LocalDirectory_CheckErr
  113. )
  114. IF NOT EXIST "%LocalDirectory.Restore%" (
  115.     MKDIR "%LocalDirectory.Restore%" || GOTO :Prerequisites_LocalDirectory_CheckErr
  116. )
  117. IF NOT EXIST "%LocalDirectory.Logs%" (
  118.     MKDIR "%LocalDirectory.Logs%" || GOTO :Prerequisites_LocalDirectory_CheckErr
  119. )
  120. EXIT /B 0
  121.  
  122.  
  123.  
  124.  
  125. REM =====================================================================
  126. REM Global Functions
  127. REM ----------------------------
  128. REM These functions listed below is used to reduce redundancy within the code.
  129. REM =====================================================================
  130.  
  131.  
  132. REM # =============================================================================================
  133. REM # Documentation: This function simply clears the terminal buffer and also the StandardIn [STDIN] identifier.
  134. REM # =============================================================================================
  135. :ClearBuffer
  136. CLS
  137. REM Clear the STDIN
  138. SET STDIN=
  139. GOTO :EOF
  140.  
  141.  
  142.  
  143. REM # =============================================================================================
  144. REM # Documentation: This function captures the user's input from the keyboard.
  145. REM # =============================================================================================
  146. :UserInput
  147. ECHO.
  148. ECHO %SeparatorSmall%
  149. SET /P STDIN=^>^>^>^>
  150. GOTO :EOF
  151.  
  152.  
  153.  
  154. REM # =============================================================================================
  155. REM # Documentation: This function determines wither to render the Dashboard Viewer tool or only the classical header.  This is determined by the users settings based from the core, not this module.
  156. REM # =============================================================================================
  157. :DashboardOrClassicalDisplay
  158. IF %DashboardViewerTool% EQU True (
  159.     CALL :Dashboard
  160. ) ELSE (
  161.     ECHO %ProjectName% Module Version: %ProjectVersion%
  162. )
  163. GOTO :EOF
  164.  
  165.  
  166.  
  167. REM # =============================================================================================
  168. REM # Parameters: [{String} Target]
  169. REM # Documentation: This function will call the Windows Explorer and open the destination that is given when calling this function with a parameter.
  170. REM # =============================================================================================
  171. :Call_WindowsExplorer
  172. EXPLORER "%~1"
  173. GOTO :EOF
  174.  
  175.  
  176.  
  177. REM # =============================================================================================
  178. REM # Documentation: This function will be called when the user's input does not meet the criteria that the program was wanting.  This is typically used when using the menu selections.
  179. REM # =============================================================================================
  180. :BadInput
  181. ECHO.&ECHO.
  182. ECHO ^<!^>       Invalid Input       ^<!^>
  183. ECHO %SeparatorLong%
  184. ECHO.
  185. ECHO !ERR: Incorrect feedback from the user.
  186. ECHO User Feedback: "%STDIN%"
  187. ECHO.
  188. PAUSE
  189. CALL :ClearBuffer
  190. GOTO :EOF
  191.  
  192.  
  193.  
  194.  
  195. REM =====================================================================
  196. REM Dashboard
  197. REM ----------------------------
  198. REM The dashboard here is to only highlight important and display what the user needs to know for the program to work correctly.
  199. REM The idea of this dashboard, is to NOT be so verbose or full of details, but only display quick and brief details.
  200. REM This feature can be rather intensive as this does detections, which requires reads and writes within the memory field.  Disabling this feature can slightly improve the performance.
  201. REM =====================================================================
  202.  
  203.  
  204. REM # =============================================================================================
  205. REM # Documentation: The main header for the Dashboard Viewer tool.
  206. REM # =============================================================================================
  207. :Dashboard
  208. CALL :Dashboard_HeaderBorder
  209. ECHO                  Dashboard Viewer
  210. ECHO Ver: %ProjectVersion%                           %ReleaseDate%
  211. ECHO Preset: %UserConfigurationLoaded%
  212. CALL :Dashboard_CallDetection
  213. CALL :Dashboard_FooterBorder
  214. CALL :Dashboard_ExtraLineBreaks
  215. GOTO :EOF
  216.  
  217.  
  218.  
  219. REM # =============================================================================================
  220. REM # Documentation: This function tries to find errors that could prevent the program from working efficiently.  If errors were found, this will add warning notifications within the dashboard.
  221. REM # =============================================================================================
  222. :Dashboard_CallDetection
  223. CALL :DashboardDetection
  224. IF %ERRORLEVEL% EQU 1 (
  225.    REM Some resources didn't pass through the detection
  226.     ECHO.
  227.     ECHO Warning^(s^): %ProcessVarB%
  228.     ECHO %SeparatorSmall%
  229.     ECHO %ProcessVarA%
  230. )
  231. GOTO :EOF
  232.  
  233.  
  234.  
  235. REM # =============================================================================================
  236. REM # Documentation: This adds additional lines to help prevent the Dashboard Viewer tool from being crowded with the main content of the program.
  237. REM # =============================================================================================
  238. :Dashboard_ExtraLineBreaks
  239. ECHO.&ECHO.&ECHO.
  240. GOTO :EOF
  241.  
  242.  
  243.  
  244. REM # =============================================================================================
  245. REM # Documentation: This function adds the header to the main Dashboard Viewer tool.
  246. REM # =============================================================================================
  247. :Dashboard_HeaderBorder
  248. ECHO %SeparatorLong%
  249. GOTO :EOF
  250.  
  251.  
  252.  
  253. REM # =============================================================================================
  254. REM # Documentation: This function adds the footer to the main Dashboard Viewer tool.
  255. REM # =============================================================================================
  256. :Dashboard_FooterBorder
  257. ECHO %SeparatorLong%
  258. ECHO %SeparatorLong%
  259. GOTO :EOF
  260.  
  261.  
  262.  
  263.  
  264. REM =====================================================================
  265. REM Dashboard - Detection
  266. REM ----------------------------
  267. REM This is merely an extended version of the dashboard feature, though this includes further checks.
  268. REM =====================================================================
  269.  
  270.  
  271. REM # =============================================================================================
  272. REM # Documentation: This function executes the entire detection procedure for the Dashboard Viewer Tool.
  273. REM # =============================================================================================
  274. :DashboardDetection
  275. CALL :DashboardDetection_CheckResources
  276. IF %ProcessVarB% NEQ 0 EXIT /B 1
  277. EXIT /B 0
  278.  
  279.  
  280.  
  281. REM # =============================================================================================
  282. REM # Documentation: This function scans for warnings that could cause problems when attempting to compile the project.
  283. REM # =============================================================================================
  284. :DashboardDetection_CheckResources
  285. REM Clear the variables
  286. SET ProcessVarA=
  287. SET ProcessVarB=0
  288. CALL :DashboardDetection_7Zip
  289. IF %ERRORLEVEL% EQU 1 (
  290.     SET "ProcessVarA=%ProcessVarA%7Zip - Not Found!&ECHO."
  291.     SET /A ProcessVarB=%ProcessVarB%+1
  292. )
  293. GOTO :EOF
  294.  
  295.  
  296.  
  297. REM # =============================================================================================
  298. REM # Documentation: Was the 7Zip software detected from the core?
  299. REM # =============================================================================================
  300. :DashboardDetection_7Zip
  301. IF %Detect_7Zip% EQU False EXIT /B 1
  302. EXIT /B 0
  303.  
  304.  
  305.  
  306.  
  307. REM =====================================================================
  308. REM Module Initialization Driver
  309. REM ----------------------------
  310. REM This section will manage how to either initialize identifiers for the module environment or if the configuration needs to be saved to a preset file.
  311. REM =====================================================================
  312.  
  313.  
  314. REM # =============================================================================================
  315. REM # Parameters: [{String} Mode] [{String} Options] [{String} TargetPath]
  316. REM # Documentation: This function, depending how it is called - which is set by the first parameter [MODE], will help set up the environment for the program, create or update a user configuration, or update the project resource targets [plugins, directories, etc].
  317. REM # =============================================================================================
  318. :Initialization_Driver
  319. REM This driver requires parameters:
  320. REM     [Mode] (OPTIONS) (PATH)
  321. REM When starting the program, this function will be executed.
  322. IF %1 EQU Load (
  323.    REM Parameters: [Mode = Load]
  324.    REM Load the environment field when starting up the program or when this block is executed.
  325.     CALL :Initialization_IdentifiersStatic
  326.     CALL :Initialization_IdentifiersUserSettings 0
  327.     CALL :Initialization_LocalDirectories 2
  328.     CALL :UserPreset_Driver 0
  329.     CALL :Initialization_UpdateLogging
  330.     GOTO :EOF
  331. )
  332. IF %1 EQU SaveUserConfig (
  333.    REM Parameters: [Mode = SaveUserConfig] [File to Output]
  334.    REM Write the current user configuration that is in current active memory and write it to a file.
  335.     CALL :Initialization_IdentifiersUserSettings 1 "%~2"
  336.     CALL :Initialization_LocalDirectories 1 "%~2"
  337.     GOTO :EOF
  338. )
  339. IF %1 EQU UpdateLocalDirectoryLocation (
  340.    REM Parameters: [Mode = UpdateLocalDirectoryLocation] [New Path]
  341.    REM Change the Local Directories default location to a user specified
  342.     CALL :Initialization_LocalDirectories 3 "%~2"
  343.     GOTO :EOF
  344. )
  345. IF %1 EQU RestoreLocalDirectoryLocation (
  346.    REM Parameters: [Mode = RestoreLocalDirectoryLocation]
  347.    REM Revert the local directories default location
  348.     CALL :Initialization_LocalDirectories 2
  349.     GOTO :EOF
  350. )
  351. IF %1 EQU UpdateLocalDirectorySubLocation (
  352.    REM This is used when loading from a save preset, just re-flash the local sub directory variables.
  353.    REM  With the way that this is designed, it is a bit wasteful of resources.
  354.     CALL :Initialization_LocalDirectories 0
  355.     GOTO :EOF
  356. )
  357.  
  358.  
  359.  
  360. REM # =============================================================================================
  361. REM # Documentation: This function sets the static environment for the module, and other variables that is self managed 1ithin the program.
  362. REM # =============================================================================================
  363. :Initialization_IdentifiersStatic
  364. REM Static Variables
  365. SET ProjectName=DeLorean
  366. SET ProjectVersion=5.2
  367. SET ReleaseDate=5.March.2015
  368. REM This sets up the archive based name, this is used for the backup process.
  369. SET "Backup_FileName=Backup-[%ComputerName%]_%core.Date%"
  370. REM The general output file name for the restore and backup process
  371. SET Output=UNKNOWN
  372. REM This variable houses the source target; this is primarily for restoring functionality.
  373. SET Source=UNKNOWN
  374. REM This variable holds the archive's encryption password, this is primarily used for the Restoring functionality.
  375. SET ArchivePassword=UNKNOWN
  376. REM 7Zip Exclusion List, used to avoid 7Zip from accessing junction loops.
  377. SET Backup_ExclusionList=UNKNOWN
  378. REM Error Signal for Operations; if the value is not null, there was a general issue with a function or functions in sequence.
  379. SET ErrorSignal=0
  380. REM Exit Code captures ErrorLevel - but retains the xid.
  381. SET ExitCode=0
  382. REM Fatal Exit retains the exit code from the lower level [spine of the program]; if there is an error from the lower level, then this variable will be updated.
  383. SET FatalExit=0
  384. REM What internal or external CMD was called, this is going to be used primarily for logs and error messages.  Make this easy for the user to understand what program was called, do not make it complicated.
  385. SET TaskCaller_NiceProgramName=NULL
  386. REM Compiled version of 'TaskCaller' into one string.
  387. SET TaskCaller_CallLong=NULL
  388. REM This houses the parameters for 7Zip, this gets filled when we need to invoke it.
  389. SET SevenZipCompactParameters=-
  390. REM This variable is used to describe the drivers main purpose and present the value in the log files.
  391. SET DriversNiceTask=UNKNOWN
  392. GOTO :EOF
  393.  
  394.  
  395.  
  396. REM # =============================================================================================
  397. REM # Parameters: [{Int} Mode] IF MODE = 3 "[{String} LocalDirectoryPath]" OR IF MODE = 2 "[{String} UserConfigOutput]"
  398. REM # Documentation: This function will set the Local Directory targets.  These local directories are necessary for the program to work correctly.
  399. REM #  First Parameter:
  400. REM #   0 = Read\Load
  401. REM #   1 = Write to specific file
  402. REM #   2 = Use Default Root Path
  403. REM #   3 = Use New Root Path
  404. REM #  Second Parameter:
  405. REM #   Output File
  406. REM # =============================================================================================
  407. :Initialization_LocalDirectories
  408. REM Note: DirLocal is merely a simple dedicated directory for output data and saved data.
  409. REM ----
  410. REM Output to a save file
  411. IF %1 EQU 1 (ECHO REM Local Directory [root])>> "%~2"
  412. IF %1 EQU 1 (ECHO REM --------------------)>> "%~2"
  413. IF %1 EQU 1 (ECHO SET "LocalDirectory.MainRoot=%LocalDirectory.MainRoot%")>> "%~2"
  414. IF %1 EQU 1 GOTO :EOF
  415. REM ----
  416.  
  417. REM Main root
  418. REM ----
  419. REM Default Root
  420. IF %1 EQU 2 (SET "LocalDirectory.MainRoot=%DirProjects%\%ProjectName%")
  421. REM Update the Root
  422. IF %1 EQU 3 (SET "LocalDirectory.MainRoot=%~2\%ProjectName%")
  423. REM ----
  424.  
  425. REM Special Cases
  426. REM ----
  427. REM Preset Configurations -- DO NOT UPDATE THIS IF THE USER CHANGES THE PATH!
  428. IF %1 EQU 2 (SET "LocalDirectory.UserConfig=%LocalDirectory.MainRoot%\Config")
  429. REM ----
  430. REM Temporary data
  431. SET "LocalDirectory.Temp=%LocalDirectory.MainRoot%\Temp"
  432. REM Backup Database
  433. SET "LocalDirectory.Backup=%LocalDirectory.MainRoot%\Backup"
  434. REM Restored Database
  435. SET "LocalDirectory.Restore=%LocalDirectory.MainRoot%\Restore"
  436. REM Log Files
  437. SET "LocalDirectory.Logs=%LocalDirectory.MainRoot%\Log"
  438. GOTO :EOF
  439.  
  440.  
  441.  
  442. REM # =============================================================================================
  443. REM # Parameters: [{Int} Mode] [{String} UserConfigOutput]
  444. REM # Documentation: This function houses the users settings and customizations; this manages both loading and writing to a file, depending on the argument when this function is called.
  445. REM #  First Parameter:
  446. REM #   0 = Read\Load
  447. REM #   1 = Write to specific file
  448. REM #  Second Parameter:
  449. REM #   Output File
  450. REM # =============================================================================================
  451. :Initialization_IdentifiersUserSettings
  452. REM --------------------------------
  453. REM ================================
  454. IF %1 EQU 1 (ECHO.)>> "%~2"
  455. REM 7Zip Settings
  456. REM -------------------------------------
  457. IF %1 EQU 1 (ECHO REM 7Zip Settings)>> "%~2"
  458. IF %1 EQU 1 (ECHO REM --------------------)>> "%~2"
  459. REM ----
  460. REM Encrypt compressed data with a password?
  461. IF %1 EQU 0 (SET UserConfig.7ZipUseKey=False)
  462. IF %1 EQU 1 (ECHO REM Encrypt compressed data with a password?)>> "%~2"
  463. IF %1 EQU 1 (ECHO SET UserConfig.7ZipUseKey=%UserConfig.7ZipUseKey%)>> "%~2"
  464. REM ----
  465.  
  466.  
  467. IF %1 EQU 1 (ECHO.)>> "%~2"
  468. REM Program Management Settings
  469. REM -------------------------------------
  470. IF %1 EQU 1 (ECHO REM Program Management Settings)>> "%~2"
  471. IF %1 EQU 1 (ECHO REM --------------------)>> "%~2"
  472. REM ----
  473. REM Allow the program to display random quotes from the Back to the Future?
  474. IF %1 EQU 0 SET UserConfig.BackToTheFutureQuotes=True
  475. IF %1 EQU 1 (ECHO REM Allow the program to display random quotes from the Back to the Future?)>> "%~2"
  476. IF %1 EQU 1 (ECHO SET "UserConfig.BackToTheFutureQuotes=%UserConfig.BackToTheFutureQuotes%")>> "%~2"
  477. REM ----
  478. REM Exclude the user's videos directories from backup?
  479. IF %1 EQU 0 SET UserConfig.ExcludeVideos=False
  480. IF %1 EQU 1 (ECHO REM Allow the program to exclude backing up the users video directories [~\Videos, ~\My Videos, ~\My Movies, ~\Movies])>> "%~2"
  481. IF %1 EQU 1 (ECHO SET UserConfig.ExcludeVideos=%UserConfig.ExcludeVideos%)>> "%~2"
  482.  
  483.  
  484. IF %1 EQU 1 (ECHO.)>> "%~2"
  485. REM Power State Settings
  486. REM -------------------------------------
  487. IF %1 EQU 1 (ECHO REM Power State Settings)>> "%~2"
  488. IF %1 EQU 1 (ECHO REM --------------------)>> "%~2"
  489. REM ----
  490. REM Power State variable:
  491. REM     0 = Keep Running [S0]
  492. REM     1 = Sleep Mode [S3]
  493. REM     2 = Hibernation [S4]
  494. REM     3 = Shutdown
  495. IF %1 EQU 0 (SET UserConfig.PowerState=0)
  496. IF %1 EQU 1 (ECHO REM Power State)>> "%~2"
  497. IF %1 EQU 1 (ECHO SET UserConfig.PowerState=%UserConfig.PowerState%)>> "%~2"
  498. REM ----
  499. REM Grace Time Warning [in seconds]
  500. IF %1 EQU 0 (SET UserConfig.PowerStateGraceTime=300)
  501. IF %1 EQU 1 (ECHO REM Grace Time Warning [in seconds])>> "%~2"
  502. IF %1 EQU 1 (ECHO SET UserConfig.PowerStateGraceTime=%UserConfig.PowerStateGraceTime%)>> "%~2"
  503. REM ----
  504. GOTO :EOF
  505.  
  506.  
  507.  
  508. REM # =============================================================================================
  509. REM # Documentation: Update the log file name, if logging is enabled.
  510. REM # =============================================================================================
  511. :Initialization_UpdateLogging
  512. IF "%ToggleLog%" NEQ "False" SET "STDOUT=%LocalDirectory.Logs%\%ProjectName%_%core.Date%.txt"
  513. GOTO :EOF
  514.  
  515.  
  516.  
  517.  
  518. REM =====================================================================
  519. REM Main Menu Interaction Field
  520. REM ----------------------------
  521. REM The main menu for the module program.
  522. REM =====================================================================
  523.  
  524.  
  525. REM # =============================================================================================
  526. REM # Documentation: Main menu of the program.
  527. REM # =============================================================================================
  528. :MainMenu
  529. CALL :DashboardOrClassicalDisplay
  530. CALL :QuoteDatabase
  531. ECHO %ProjectName% Menu
  532. ECHO %Separator%
  533. ECHO.
  534. ECHO Main Tasks
  535. ECHO %SeparatorSmall%
  536. ECHO [1] Backup
  537. ECHO [2] Restore
  538. ECHO.
  539. ECHO Other Options
  540. ECHO %SeparatorSmall%
  541. ECHO [S] Settings
  542. ECHO [V] View Directories
  543. ECHO [C] Cleanup
  544. ECHO [U] Check for Updates
  545. ECHO [X] Exit
  546. CALL :UserInput
  547. GOTO :Menu_UserInput
  548.  
  549.  
  550.  
  551. REM # =============================================================================================
  552. REM # Documentation: Inspect the users input.
  553. REM # =============================================================================================
  554. :Menu_UserInput
  555. IF "%STDIN%" EQU "1" GOTO :Main_Choice_Backup
  556. IF "%STDIN%" EQU "2" GOTO :Main_Choice_Restore
  557. IF /I "%STDIN%" EQU "S" GOTO :Main_Choice_Settings
  558. IF /I "%STDIN%" EQU "V" GOTO :Main_Choice_ViewDirectories
  559. IF /I "%STDIN%" EQU "C" GOTO :Main_Choice_Cleanup
  560. IF /I "%STDIN%" EQU "U" GOTO :Main_Choice_Updates
  561. IF /I "%STDIN%" EQU "X" GOTO :EOF
  562. IF /I "%STDIN%" EQU "Cancel" GOTO :EOF
  563. CALL :BadInput& GOTO :MainMenu
  564.  
  565.  
  566.  
  567. REM # =============================================================================================
  568. REM # Documentation: Backup the users data
  569. REM # =============================================================================================
  570. :Main_Choice_Backup
  571. CALL :ClearBuffer
  572. CALL :Backup
  573. CALL :ClearBuffer
  574. GOTO :MainMenu
  575.  
  576.  
  577.  
  578. REM # =============================================================================================
  579. REM # Documentation: Restore the users data
  580. REM # =============================================================================================
  581. :Main_Choice_Restore
  582. CALL :ClearBuffer
  583. CALL :Restore
  584. CALL :ClearBuffer
  585. GOTO :MainMenu
  586.  
  587.  
  588.  
  589. REM # =============================================================================================
  590. REM # Documentation: Access the control panel.
  591. REM # =============================================================================================
  592. :Main_Choice_Settings
  593. CALL :ClearBuffer
  594. CALL :Settings
  595. CALL :ClearBuffer
  596. GOTO :MainMenu
  597.  
  598.  
  599.  
  600. REM # =============================================================================================
  601. REM # Documentation: Check for available module updates.
  602. REM # =============================================================================================
  603. :Main_Choice_Updates
  604. CALL :ClearBuffer
  605. CALL :ModuleUpdates
  606. CALL :ClearBuffer
  607. GOTO :MainMenu
  608.  
  609.  
  610.  
  611. REM # =============================================================================================
  612. REM # Documentation: Cleanup the local directory and sub-directories.
  613. REM # =============================================================================================
  614. :Main_Choice_Cleanup
  615. CALL :ClearBuffer
  616. CALL :Cleanup
  617. CALL :ClearBuffer
  618. GOTO :MainMenu
  619.  
  620.  
  621.  
  622. REM # =============================================================================================
  623. REM # Documentation: Allow the user to simply open directories in the GUI shell.
  624. REM # =============================================================================================
  625. :Main_Choice_ViewDirectories
  626. CALL :ClearBuffer
  627. CALL :ViewDirectories
  628. CALL :ClearBuffer
  629. GOTO :MainMenu
  630.  
  631.  
  632.  
  633.  
  634. REM =====================================================================
  635. REM Main Restore Driver
  636. REM ----------------------------
  637. REM This is a simple driver for calling other functions that properly helps to restore the user's personalized data.
  638. REM =====================================================================
  639.  
  640.  
  641.  
  642. REM # =============================================================================================
  643. REM # Documentation: This driver will guide the entire restore procedure.
  644. REM # =============================================================================================
  645. :Restore
  646. REM Prompt the user with the restore menu; if the user cancels out - terminate the process.
  647. CALL :Restore_MenuSection || GOTO :EOF
  648. REM ----
  649.  
  650. REM The Restore Process
  651. CALL :DashboardOrClassicalDisplay
  652. CALL :QuoteDatabase
  653.  
  654.  
  655. REM ----
  656. REM Display the header message
  657. CALL :Operation_DisplayHeaderMessage
  658.  
  659. REM ----
  660. REM Check if the restore data already exists in the restore directory, and any other steps necessary.
  661. CALL :Restore_Prepare || (CALL :Operation_TerminateWithError& GOTO :EOF)
  662.  
  663. REM ----
  664. REM Restore the data
  665. CALL :Restore_Extract || (CALL :Operation_TerminateWithError& GOTO :EOF)
  666.  
  667. REM ----
  668. REM Completed, successfully finished
  669. CALL :Operation_TerminateSuccessfully
  670. REM Finished
  671. PAUSE
  672. GOTO :EOF
  673.  
  674.  
  675.  
  676. REM # =============================================================================================
  677. REM # Documentation: This section merely prompts the user with the Restore Menu
  678. REM # =============================================================================================
  679. :Restore_MenuSection
  680. REM Display the Restore menu; allow the user to select which package they want to restore from
  681. REM    Error out if the user cancels
  682. CALL :Restore_Menu || EXIT /B 1
  683. REM ----
  684. REM Clear the terminal screen
  685. CALL :ClearBuffer
  686. EXIT /B 0
  687.  
  688.  
  689.  
  690.  
  691. REM =====================================================================
  692. REM Restore: Main Menu
  693. REM ----------------------------
  694. REM This will print the restore menu on the screen and allows the user to pick which archive to extract automatically for them.
  695. REM =====================================================================
  696.  
  697.  
  698. REM # =============================================================================================
  699. REM # Documentation: Restore Menu
  700. REM # =============================================================================================
  701. :Restore_Menu
  702. CALL :DashboardOrClassicalDisplay
  703. CALL :QuoteDatabase
  704. ECHO Restore Menu
  705. ECHO %Separator%
  706. ECHO.
  707. ECHO Available Backups:
  708. ECHO %SeparatorLong%
  709. ECHO.
  710. DIR "%LocalDirectory.Backup%" /B /O:-D /P
  711. ECHO.
  712. ECHO %SeparatorLong%
  713. ECHO.
  714. ECHO Type the full name [with file extension] of the backup file to restore
  715. ECHO   Warning: Do _NOT_ use quotes!
  716. ECHO.
  717. ECHO Other Options
  718. ECHO %SeparatorSmall%
  719. ECHO [X] Exit
  720. CALL :UserInput
  721. GOTO :Restore_Menu_UserInput
  722.  
  723.  
  724.  
  725. REM # =============================================================================================
  726. REM # Documentation: Inspect the user's input
  727. REM # =============================================================================================
  728. :Restore_Menu_UserInput
  729. IF /I "%STDIN%" EQU "X" GOTO :EOF
  730. IF /I "%STDIN%" EQU "Cancel" GOTO :EOF
  731. REM Does file exist or is it invalid
  732. IF NOT EXIST "%LocalDirectory.Backup%\%STDIN%" (
  733.     CALL :BadInput
  734.     GOTO :Restore_Menu
  735. )
  736. CALL :Restore_Menu_UpdateVars "%STDIN%"
  737. CALL :Restore_Menu_Password
  738. CALL :ClearBuffer
  739. EXIT /B 0
  740.  
  741.  
  742.  
  743. REM # =============================================================================================
  744. REM # Parameters: [{String} ArchiveName]
  745. REM # Documentation: Cache the user's requested archive to backup with the exact paths.
  746. REM # =============================================================================================
  747. :Restore_Menu_UpdateVars
  748. SET "Source=%LocalDirectory.Backup%\%~1"
  749. REM Output the contents in 'Output'
  750. SET "Output=%LocalDirectory.Restore%\%~1"
  751. GOTO :EOF
  752.  
  753.  
  754.  
  755. REM # =============================================================================================
  756. REM # Documentation: Prompt the user for the password that is possibly used for the archive .
  757. REM # =============================================================================================
  758. :Restore_Menu_Password
  759. ECHO.& ECHO.
  760. REM ----
  761. ECHO Enter the password that was used for encrypting the data; leave blank if there's no password.
  762. ECHO Enter Password:
  763. CALL :UserInput
  764. REM ----
  765. SET "ArchivePassword=%STDIN%"
  766. GOTO :EOF
  767.  
  768.  
  769.  
  770.  
  771. REM =====================================================================
  772. REM Restore: Restore Preparations
  773. REM ----------------------------
  774. REM In this section, the program will merely setup any last minute updates\configurations and anything else that is required for the restoration process.
  775. REM =====================================================================
  776.  
  777.  
  778.  
  779. REM # =============================================================================================
  780. REM # Documentation: The prepare function will guide through the preparation process.
  781. REM # =============================================================================================
  782. :Restore_Prepare
  783. SET "DriversNiceTask=Preparing restore process"
  784. REM Print on the screen that the program is preparing
  785. CALL :Operation_Display_IncomingTask "%DriversNiceTask%"
  786. REM ----
  787. REM Check to make sure there isn't going to be a duplication conflicts
  788. CALL :Restore_Prepare_CheckExists || (CALL :CaughtIssueSignal& EXIT /B 1)
  789. REM ----
  790. REM Make the output directory; this will be used for extracting the contents
  791. CALL :Restore_Prepare_CreateOutput || (CALL :CaughtIssueSignal& EXIT /B 1)
  792. REM ----
  793. REM Print the footer in the log.
  794. CALL :Operation_DriverLogFooter "%DriversNiceTask%"
  795. EXIT /B 0
  796.  
  797.  
  798.  
  799. REM # =============================================================================================
  800. REM # Documentation: Check to make sure that the Restore directory does not already contain the same folder.
  801. REM # =============================================================================================
  802. :Restore_Prepare_CheckExists
  803. CALL :Operation_Display_IncomingTaskSubLevel "Checking if [ %Output% ] already exists"
  804. IF EXIST "%Output%" (
  805.     CALL :Restore_Prepare_CheckExistsErr
  806.     EXIT /B 1
  807. ) ELSE (
  808.     EXIT /B 0
  809. )
  810.  
  811.  
  812.  
  813. REM # =============================================================================================
  814. REM # Documentation: The directory exists; this will print a fatal error on the screen.
  815. REM # =============================================================================================
  816. :Restore_Prepare_CheckExistsErr
  817. CALL :Operation_Display_IncomingTaskSubLevelMSG "!ERR_CRIT!: The directory named [ %Output% ] already exists!  Can not overwrite or manage this directory!  Try managing the contents manually using the View Directories option or run the Cleanup on the Restore directory."
  818. GOTO :EOF
  819.  
  820.  
  821.  
  822. REM # =============================================================================================
  823. REM # Documentation: The directory could not be created; this directory is needed for the extraction point.  Without it, we can't extract the data in a 'neater' fashion.
  824. REM # =============================================================================================
  825. :Restore_CheckExists_MakeDirErr
  826. CALL :Operation_Display_IncomingTaskSubLevelMSG "!ERR_CRIT!: The directory named [ %Output% ] could not be created!"
  827. GOTO :EOF
  828.  
  829.  
  830.  
  831. REM # =============================================================================================
  832. REM # Documentation: This function will make sure that the output path is properly created and available for the program to utilize.
  833. REM # =============================================================================================
  834. :Restore_Prepare_CreateOutput
  835. CALL :Operation_Display_IncomingTaskSubLevel "Creating the output directory [ %Output% ]"
  836. CALL :Restore_Prepare_CreateOutput_Task || CALL :Restore_CheckExists_MakeDirErr
  837. EXIT /B %ERRORLEVEL%
  838.  
  839.  
  840.  
  841. :Restore_Prepare_CreateOutput_Task
  842. SET TaskCaller_NiceProgramName=MKDIR
  843. SET TaskCaller_CallLong=MKDIR "%Output%"
  844. CALL :Operation_TaskOperation
  845. EXIT /B %ExitCode%
  846.  
  847.  
  848.  
  849.  
  850. REM =====================================================================
  851. REM Restore: Extracting \ Restore
  852. REM ----------------------------
  853. REM This section will manage the extraction process of the archive file.
  854. REM =====================================================================
  855.  
  856.  
  857.  
  858. REM # =============================================================================================
  859. REM # Documentation: This function will create the output path that is going to be the placeholder for the archive extraction.
  860. REM # =============================================================================================
  861. :Restore_Extract
  862. REM Display that we're starting the backup process
  863. SET "DriversNiceTask=Restore the data"
  864. CALL :Operation_Display_IncomingTask "%DriversNiceTask%"
  865. REM ----
  866. REM Build the parameters
  867. CALL :Restore_Extract_ParameterBuild
  868. REM ----
  869. REM Call the actual process
  870. CALL :Restore_Extract_Task || (CALL :Restore_ExtractErr& CALL :CaughtErrorSignal& EXIT /B 1)
  871. REM ----
  872. REM Print the footer in the log.
  873. CALL :Operation_DriverLogFooter "%DriversNiceTask%"
  874. EXIT /B 0
  875.  
  876.  
  877. REM # =============================================================================================
  878. REM # Documentation: Extract the backup contents from the archive file
  879. REM # =============================================================================================
  880. :Restore_Extract_Task
  881. CALL :Operation_Display_IncomingTaskSubLevel "Extracting the data"
  882. SET TaskCaller_NiceProgramName=SevenZip
  883. SET TaskCaller_CallLong="%Path7Zip%" x %ProcessVarA%
  884. CALL :Operation_TaskOperation
  885. EXIT /B %ExitCode%
  886.  
  887.  
  888.  
  889. REM # =============================================================================================
  890. REM # Documentation: 7Zip returned an error when trying to extract the contents from the archive file
  891. REM # =============================================================================================
  892. :Restore_ExtractErr
  893. CALL :Operation_Display_IncomingTaskSubLevelMSG "!ERR_CRIT!: 7Zip could not successfully extract the contents from archive file [ %Source% ]."
  894. GOTO :EOF
  895.  
  896.  
  897.  
  898. REM # =============================================================================================
  899. REM # Documentation: 7Zip Restore Parameter Builder
  900. REM # =============================================================================================
  901. :Restore_Extract_ParameterBuild
  902. SET ProcessVarA="%Source%" -o"%Output%"
  903. IF DEFINED ArchivePassword (
  904.     SET ProcessVarA=%ProcessVarA% -p%ArchivePassword%
  905. )
  906. GOTO :EOF
  907.  
  908.  
  909.  
  910.  
  911. REM =====================================================================
  912. REM Main Backup Driver
  913. REM ----------------------------
  914. REM This is a simple driver for calling other functions that properly helps to backup the user's personalized data.
  915. REM =====================================================================
  916.  
  917.  
  918. REM # =============================================================================================
  919. REM # Documentation: This driver will guide the entire backup procedure.
  920. REM # =============================================================================================
  921. :Backup
  922. CALL :DashboardOrClassicalDisplay
  923. CALL :QuoteDatabase
  924.  
  925. REM ----
  926. REM Display the header message
  927. CALL :Operation_DisplayHeaderMessage
  928.  
  929. REM ----
  930. REM Flush the Temporary directory; if in-case anything was there previously
  931. CALL :Backup_FlushTempDirectory || (CALL :Operation_TerminateWithError& GOTO :EOF)
  932.  
  933. REM ----
  934. REM Prepare the environment for the backup process.
  935. CALL :Backup_Prepare || (CALL :Operation_TerminateWithError& GOTO :EOF)
  936.  
  937. REM ----
  938. REM Check to make sure that all prerequisites and dependencies are available and ready to be used.  This detection is important, otherwise - everything will be a waste of time if some minor issue occurs.
  939. CALL :Backup_CheckResources || (CALL :Operation_TerminateWithError& GOTO :EOF)
  940.  
  941. REM ----
  942. REM Call the Backup Driver
  943. CALL :Backup_Compact || (CALL :Operation_TerminateWithError& GOTO :EOF)
  944.  
  945. REM ----
  946. REM Test the archive file
  947. CALL :Backup_Test || (CALL :Operation_TerminateWithError& GOTO :EOF)
  948.  
  949. REM ----
  950. REM Flush the Temporary directory; if in-case anything was there previously
  951. CALL :Backup_FlushTempDirectory || (CALL :Operation_TerminateWithError& GOTO :EOF)
  952.  
  953. REM ----
  954. REM Completed, successfully finished
  955. CALL :Operation_TerminateSuccessfully
  956. REM Check Power Settings; wither or not the system needs to be hibernated, enter sleep mode, etc.
  957. CALL :PowerState
  958. REM Finished
  959. PAUSE
  960. GOTO :EOF
  961.  
  962.  
  963.  
  964.  
  965. REM =====================================================================
  966. REM Backup: Backup Preparations
  967. REM ----------------------------
  968. REM In this section, the program will merely setup any last minute updates\configurations and anything else that is required for the backup process.
  969. REM =====================================================================
  970.  
  971.  
  972. REM # =============================================================================================
  973. REM # Documentation: Within this section, we're preparing the entire backup process.
  974. REM # =============================================================================================
  975. :Backup_Prepare
  976. REM This variable is used to describe the drivers main purpose and present the value in the log files.
  977. SET "DriversNiceTask=Preparing backup process"
  978. REM Print on the screen that the program is preparing
  979. CALL :Operation_Display_IncomingTask "%DriversNiceTask%"
  980. REM ----
  981. REM Initialize some runtime variables
  982. CALL :Backup_Prepare_Initializations
  983. REM ----
  984. REM Generate the exclusions list
  985. CALL :Backup_Prepare_BuildExclusionList_Manager "%Backup_ExclusionList%" || EXIT /B 1
  986. REM ----
  987. REM Print the footer in the log.
  988. CALL :Operation_DriverLogFooter "%DriversNiceTask%"
  989. EXIT /B 0
  990.  
  991.  
  992.  
  993. REM # =============================================================================================
  994. REM # Parameters: [{string}FileName]
  995. REM # Documentation: Here, this will easily guide the process of generating the exclusions list for 7Zip
  996. REM # =============================================================================================
  997. :Backup_Prepare_BuildExclusionList_Manager
  998. CALL :Operation_Display_IncomingTaskSubLevel "Building Exclusions list"
  999. CALL :Backup_Prepare_BuildExclusionList "%~1"
  1000. CALL :Backup_Prepare_BuildExclusionList_UserVideos "%~1"
  1001. CALL :Backup_Prepare_BuildExclusionList_FileCheck "%~1" || (CALL :ResourceErrorSignal "%~1"& EXIT /B 1)
  1002. EXIT /B 0
  1003.  
  1004.  
  1005.  
  1006. REM # =============================================================================================
  1007. REM # Parameters: [{string}FileName]
  1008. REM # Documentation: This will create an exclusion list that is going to be used with 7Zip.  This will avoid 7Zip from accessing nasty directories that it does not yet support -- junction pointers.  The list will always be built to assure that %USERNAME% is accurate; the location will be in the temporary directory.
  1009. REM #   Note: As 7Zip doesn't work with absolute paths when excluding files or directories, we have to assume the user name given in %UserProfile% matches in %UserName%.
  1010. REM # =============================================================================================
  1011. :Backup_Prepare_BuildExclusionList
  1012. CALL :Operation_Display_IncomingTaskSubLevelMSG "Generating Exclusion list"
  1013. (ECHO "%USERNAME%\Application Data")>> "%~1"
  1014. (ECHO "%USERNAME%\AppData")>> "%~1"
  1015. (ECHO "%USERNAME%\Cookies")>> "%~1"
  1016. (ECHO "%USERNAME%\Local Settings")>> "%~1"
  1017. (ECHO "%USERNAME%\My Documents")>> "%~1"
  1018. (ECHO "%USERNAME%\NetHood")>> "%~1"
  1019. (ECHO "%USERNAME%\PrintHood")>> "%~1"
  1020. (ECHO "%USERNAME%\Recent")>> "%~1"
  1021. (ECHO "%USERNAME%\Searches")>> "%~1"
  1022. (ECHO "%USERNAME%\SendTo")>> "%~1"
  1023. (ECHO "%USERNAME%\Start Menu")>> "%~1"
  1024. (ECHO "%USERNAME%\Templates")>> "%~1"
  1025. (ECHO "%USERNAME%\NTUSER.DAT*")>> "%~1"
  1026. (ECHO "%USERNAME%\ntuser.ini")>> "%~1"
  1027. (ECHO "%USERNAME%\SkyDrive")>> "%~1"
  1028. (ECHO "%USERNAME%\OneDrive")>> "%~1"
  1029. GOTO :EOF
  1030.  
  1031.  
  1032.  
  1033. REM # =============================================================================================
  1034. REM # Parameters: [{string}FileName]
  1035. REM # Documentation: This will add-on more directories to also exclude; if the user decides to exclude their video directories.
  1036. REM # =============================================================================================
  1037. :Backup_Prepare_BuildExclusionList_UserVideos
  1038. CALL :Operation_Display_IncomingTaskSubLevelMSG "Adding video directories to the exclusion list"
  1039. REM ----
  1040. REM Does the user really want to exclude their videos from the backup procedure?
  1041. IF %UserConfig.ExcludeVideos% EQU False (
  1042.    REM The user wants their videos backed up.
  1043.     CALL :Operation_Display_IncomingTaskSubLevelMSG "Skipping; user requested"
  1044.     GOTO :EOF
  1045. )
  1046. REM ----
  1047. (ECHO "%USERNAME%\Videos")>> "%~1"
  1048. (ECHO "%USERNAME%\My Videos")>> "%~1"
  1049. (ECHO "%USERNAME%\MyVideos")>> "%~1"
  1050. (ECHO "%USERNAME%\Movies")>> "%~1"
  1051. (ECHO "%USERNAME%\My Movies")>> "%~1"
  1052. (ECHO "%USERNAME%\MyMovies")>> "%~1"
  1053. GOTO :EOF
  1054.  
  1055.  
  1056. REM # =============================================================================================
  1057. REM # Parameters: [{string}FileName]
  1058. REM # Documentation: This small function merely makes sure that the exclusions list was created within the filesystem.
  1059. REM # =============================================================================================
  1060. :Backup_Prepare_BuildExclusionList_FileCheck
  1061. CALL :Operation_Display_IncomingTaskSubLevelMSG "Making sure the exclusion list '%~1' exists"
  1062. IF NOT EXIST "%~1" (
  1063.     EXIT /B 1
  1064. ) ELSE (
  1065.     EXIT /B 0
  1066. )
  1067.  
  1068.  
  1069.  
  1070. REM # =============================================================================================
  1071. REM # Documentation: This function will update any mutable variables that is needed within the entire backup process.
  1072. REM # =============================================================================================
  1073. :Backup_Prepare_Initializations
  1074. CALL :Operation_Display_IncomingTaskSubLevel "Initializing RunTime mutable variables"
  1075. SET "Output=%LocalDirectory.Backup%\%Backup_FileName%"
  1076. SET "Backup_ExclusionList=%LocalDirectory.Temp%\exclusions.txt"
  1077. GOTO :EOF
  1078.  
  1079.  
  1080.  
  1081.  
  1082. REM =====================================================================
  1083. REM Backup: Thrash Temporary Contents
  1084. REM ----------------------------
  1085. REM This section will thrash all of the contents that is within the temporary directory.  This will make sure that all of the contents that is still stored within the directory is - expunged and not confused with the newer backup image or left over data that is hogging additional secondary storage within the system.
  1086. REM =====================================================================
  1087.  
  1088.  
  1089. REM # =============================================================================================
  1090. REM # Documentation: This manager will make sure that the temporary files are thrashed
  1091. REM # =============================================================================================
  1092. :Backup_FlushTempDirectory
  1093. REM This variable is used to describe the drivers main purpose and present the value in the log files.
  1094. SET "DriversNiceTask=Thrash the local temporary directory"
  1095. REM Print on the screen that the program is trying to self-check
  1096. CALL :Operation_Display_IncomingTask "%DriversNiceTask%"
  1097. REM ----
  1098. CALL :Backup_FlushTempDirectory_Thrash || (CALL :CaughtIssueSignal& EXIT /B 1)
  1099. REM ----
  1100. REM Print the footer in the log.
  1101. CALL :Operation_DriverLogFooter "%DriversNiceTask%"
  1102. EXIT /B 0
  1103.  
  1104.  
  1105.  
  1106. REM # =============================================================================================
  1107. REM # Documentation: This function will thrash the temporary directory's contents.
  1108. REM # =============================================================================================
  1109. :Backup_FlushTempDirectory_Thrash
  1110. CALL :Operation_Display_IncomingTaskSubLevel "Flushing the local temporary directory"
  1111. REM Expunge all data from the directories and subdirectories
  1112. CALL :Backup_FlushTempDirectory_Thrash_PhaseOne || (CALL :Backup_FlushTempDirectory_Thrash_Err& EXIT /B 1)
  1113. CALL :Backup_FlushTempDirectory_Thrash_PhaseTwo || (CALL :Backup_FlushTempDirectory_Thrash_Err& EXIT /B 1)
  1114. EXIT /B 0
  1115.  
  1116.  
  1117.  
  1118. REM # =============================================================================================
  1119. REM # Documentation: Expunge the files within the directory.
  1120. REM # =============================================================================================
  1121. :Backup_FlushTempDirectory_Thrash_PhaseOne
  1122. CALL :Operation_Display_IncomingTaskSubLevelMSG "Deleting data from %LocalDirectory.Temp%\*.*"
  1123. REM Do not push this through "Operation_TaskOperation" function; this could cause the terminal to be 'Ghosting' and lose ALL processes.  Did I find a Windows Batch Shell bug?
  1124. DEL /F /Q /S "%LocalDirectory.Temp%\*.*" > NUL || EXIT /B 1
  1125. EXIT /B %ERRORLEVEL%
  1126.  
  1127.  
  1128.  
  1129. REM # =============================================================================================
  1130. REM # Documentation: Expunge all of the sub-directories.
  1131. REM # =============================================================================================
  1132. :Backup_FlushTempDirectory_Thrash_PhaseTwo
  1133. CALL :Operation_Display_IncomingTaskSubLevelMSG "Removing subdirectories in %LocalDirectory.Temp%\*.*"
  1134. REM Do not push this through "Operation_TaskOperation" function; this could cause the terminal to be 'Ghosting' and lose ALL processes.  Did I find a Windows Batch Shell bug?
  1135. FOR /D %%i IN ("%LocalDirectory.Temp%\*") DO RMDIR /Q /S "%%i" || EXIT /B 1
  1136. EXIT /B %ERRORLEVEL%
  1137.  
  1138.  
  1139.  
  1140. REM # =============================================================================================
  1141. REM # Documentation: Failed to thrash the temporary directory.
  1142. REM # =============================================================================================
  1143. :Backup_FlushTempDirectory_Thrash_Err
  1144. CALL :Operation_Display_IncomingTaskSubLevelMSG "!ERR_CRIT!: Could not properly thrash the temporary directory!"
  1145. GOTO :EOF
  1146.  
  1147.  
  1148.  
  1149.  
  1150. REM =====================================================================
  1151. REM Backup: Compact
  1152. REM ----------------------------
  1153. REM This section will manage compacting the user's data from their home directory.
  1154. REM =====================================================================
  1155.  
  1156.  
  1157. REM # =============================================================================================
  1158. REM # Documentation: Compact the user's home directory
  1159. REM # =============================================================================================
  1160. :Backup_Compact
  1161. REM Display that we're starting the backup process
  1162. SET "DriversNiceTask=Backing up the %UserName%'s personalized settings"
  1163. CALL :Operation_Display_IncomingTask "%DriversNiceTask%"
  1164. REM ----
  1165. REM Build the parameters
  1166. CALL :Backup_Compact_ParameterBuild
  1167. REM ----
  1168. REM Call the actual process
  1169. CALL :Backup_Compact_Task || (CALL :CaughtErrorSignal& EXIT /B 1)
  1170. REM ----
  1171. REM Print the footer in the log.
  1172. CALL :Operation_DriverLogFooter "%DriversNiceTask%"
  1173. EXIT /B 0
  1174.  
  1175.  
  1176.  
  1177. REM # =============================================================================================
  1178. REM # Documentation: Compact the user's home directory
  1179. REM # =============================================================================================
  1180. :Backup_Compact_Task
  1181. CALL :Operation_Display_IncomingTaskSubLevel "Compacting the data"
  1182. SET TaskCaller_NiceProgramName=SevenZip
  1183. SET TaskCaller_CallLong="%Path7Zip%" a %ProcessVarA%
  1184. CALL :Operation_TaskOperation
  1185. EXIT /B %ExitCode%
  1186.  
  1187.  
  1188.  
  1189. REM # =============================================================================================
  1190. REM # Documentation: 7Zip Backup Parameter Builder
  1191. REM # =============================================================================================
  1192. :Backup_Compact_ParameterBuild
  1193. SET ProcessVarA="%Output%.%SevZipFileExtension%" "%USERPROFILE%" -t%SevZipArchiveFormat% -x@"%Backup_ExclusionList%" -mx=%SevZipCompressionPass% -mmt=%SevZipMultiThreadingCPU%
  1194. IF %SevZipUseKey% EQU True (
  1195.     SET ProcessVarA=%ProcessVarA% -p%SevZipKey%
  1196. )
  1197. GOTO :EOF
  1198.  
  1199.  
  1200.  
  1201.  
  1202. REM =====================================================================
  1203. REM Backup: Testing
  1204. REM ----------------------------
  1205. REM This section will manage the integrity testing of the archive file.
  1206. REM =====================================================================
  1207.  
  1208.  
  1209. REM # =============================================================================================
  1210. REM # Documentation: Main testing driver
  1211. REM # =============================================================================================
  1212. :Backup_Test
  1213. REM Display that we're starting the backup process
  1214. SET "DriversNiceTask=Testing archive file [ %Backup_FileName% ]"
  1215. CALL :Operation_Display_IncomingTask "%DriversNiceTask%"
  1216. REM ----
  1217. REM Call the parameter builder
  1218. CALL :Backup_Compact_ParameterBuildTesting
  1219. REM ----
  1220. REM Call the actual process
  1221. CALL :Backup_Test_Task || (CALL :Backup_Test_FailureCheck& CALL :CaughtErrorSignal& EXIT /B 1)
  1222. REM ----
  1223. REM Print the footer in the log.
  1224. CALL :Operation_DriverLogFooter "%DriversNiceTask%"
  1225. EXIT /B 0
  1226.  
  1227.  
  1228.  
  1229. REM # =============================================================================================
  1230. REM # Documentation: Test the backup archive file
  1231. REM # =============================================================================================
  1232. :Backup_Test_Task
  1233. CALL :Operation_Display_IncomingTaskSubLevel "Archive integrity testing"
  1234. SET TaskCaller_NiceProgramName=SevenZip
  1235. SET TaskCaller_CallLong="%Path7Zip%" t %ProcessVarA%
  1236. CALL :Operation_TaskOperation
  1237. EXIT /B %ExitCode%
  1238.  
  1239.  
  1240.  
  1241. REM # =============================================================================================
  1242. REM # Documentation: 7Zip returned an error during the testing
  1243. REM # =============================================================================================
  1244. :Backup_Test_FailureCheck
  1245. CALL :Operation_Display_IncomingTaskSubLevelMSG "!ERR_CRIT!: 7Zip has detected that the archive file [ %Output% ] is damaged!"
  1246. GOTO :EOF
  1247.  
  1248.  
  1249.  
  1250. REM # =============================================================================================
  1251. REM # Documentation: 7Zip Testing Parameter Builder
  1252. REM # =============================================================================================
  1253. :Backup_Compact_ParameterBuildTesting
  1254. SET ProcessVarA="%Output%.%SevZipFileExtension%"
  1255. IF %SevZipUseKey% EQU True (
  1256.     SET ProcessVarA=%ProcessVarA% -p%SevZipKey%
  1257. )
  1258. GOTO :EOF
  1259.  
  1260.  
  1261.  
  1262.  
  1263. REM =====================================================================
  1264. REM Backup: Check Resources
  1265. REM ----------------------------
  1266. REM This section merely makes sure that everything is ready for the backup operation.  If this fails, the entire operation ends.
  1267. REM =====================================================================
  1268.  
  1269.  
  1270. REM # =============================================================================================
  1271. REM # Documentation: This function will make sure that the all of the resources that are necessary for this program are available and ready.  If there is _one_ issue, terminate the program - unless it is possible to _assume_ settings automatically.
  1272. REM # =============================================================================================
  1273. :Backup_CheckResources
  1274. REM This variable is used to describe the drivers main purpose and present the value in the log files.
  1275. SET "DriversNiceTask=Running Self-Check"
  1276. REM Print on the screen that the program is trying to self-check
  1277. CALL :Operation_Display_IncomingTask "%DriversNiceTask%"
  1278. REM ----
  1279. REM Check if the User's profile can be detected
  1280. CALL :Backup_CheckResources_Profile || (CALL :CaughtIssueSignal& EXIT /B 1)
  1281. REM ----
  1282. REM Check if 7Zip can be detected
  1283. CALL :Backup_CheckResources_7Zip || (CALL :CaughtIssueSignal& EXIT /B 1)
  1284. REM ----
  1285. REM Does a backup archive already exists?
  1286. CALL :Backup_CheckResources_AlreadyExists || (CALL :CaughtIssueSignal& EXIT /B 1)
  1287. REM ----
  1288. REM Print the footer in the log.
  1289. CALL :Operation_DriverLogFooter "%DriversNiceTask%"
  1290. EXIT /B 0
  1291.  
  1292.  
  1293.  
  1294. REM # =============================================================================================
  1295. REM # Documentation: Check to see if the user's Profile [or home directory] exists
  1296. REM # =============================================================================================
  1297. :Backup_CheckResources_Profile
  1298. CALL :Operation_Display_IncomingTaskSubLevel "Checking if %UserName%'s Home Directory directory exists"
  1299. IF NOT EXIST "%UserProfile%" (
  1300.    REM We can't find the user's Home Directory
  1301.     CALL :Backup_CheckResources_Profile_ERR
  1302.     EXIT /B 1
  1303. )
  1304. REM We can find the Home Directory
  1305. EXIT /B 0
  1306.  
  1307.  
  1308.  
  1309. REM # =============================================================================================
  1310. REM # Documentation: Could not find the user's home directory.  Print the message on the terminal - and log it.
  1311. REM # =============================================================================================
  1312. :Backup_CheckResources_Profile_ERR
  1313. CALL :Operation_Display_IncomingTaskSubLevelMSG "!ERR_CRIT!: Could not locate %UserName%'s profile [or Home Directory]!"
  1314. CALL :Operation_Display_IncomingTaskSubLevelMSG "This program can not continue until this issue has been resolved!"
  1315. GOTO :EOF
  1316.  
  1317.  
  1318.  
  1319. REM # =============================================================================================
  1320. REM # Documentation: Check to make sure that the 7Zip software was detected from the core.
  1321. REM # =============================================================================================
  1322. :Backup_CheckResources_7Zip
  1323. CALL :Operation_Display_IncomingTaskSubLevel "Checking if 7Zip was detected"
  1324. IF %Detect_7Zip% EQU False (
  1325.    REM We couldn't find the 7Zip software
  1326.     CALL :Backup_CheckResources_7Zip_ERR
  1327.     EXIT /B 1
  1328. )
  1329. REM Detected 7Zip
  1330. EXIT /B 0
  1331.  
  1332.  
  1333.  
  1334. REM # =============================================================================================
  1335. REM # Documentation: Could not find the 7Zip application.  Print the message on the terminal - and log it.
  1336. REM # =============================================================================================
  1337. :Backup_CheckResources_7Zip_ERR
  1338. CALL :Operation_Display_IncomingTaskSubLevelMSG "!ERR_CRIT!: Could not find 7Zip software!"
  1339. CALL :Operation_Display_IncomingTaskSubLevelMSG "This program can not continue until this issue has been resolved!"
  1340. GOTO :EOF
  1341.  
  1342.  
  1343.  
  1344. REM # =============================================================================================
  1345. REM # Documentation: Check to make sure that the archive does not already exist
  1346. REM # =============================================================================================
  1347. :Backup_CheckResources_AlreadyExists
  1348. CALL :Operation_Display_IncomingTaskSubLevel "Checking if an archive with name [ %Output% ] already exists"
  1349. IF EXIST "%Output%" (
  1350.     CALL :Backup_CheckResources_AlreadyExists_Message
  1351.     CALL :Backup_CheckResources_AlreadyExists_Prompt || EXIT /B 1
  1352.     EXIT /B 0
  1353. )
  1354. EXIT /B 0
  1355.  
  1356.  
  1357.  
  1358. REM # =============================================================================================
  1359. REM # Documentation: Display [and log it] to the user that the archive already exists
  1360. REM # =============================================================================================
  1361. :Backup_CheckResources_AlreadyExists_Message
  1362. CALL :Operation_Display_IncomingTaskSubLevelMSG "!ERR_CRIT!: Found an already existing file [ %Output% ]!"
  1363. GOTO :EOF
  1364.  
  1365.  
  1366.  
  1367. REM # =============================================================================================
  1368. REM # Documentation: Prompt the user of their choices of this slight issue; they can cancel out or delete the archive file and generate a new backup.
  1369. REM # =============================================================================================
  1370. :Backup_CheckResources_AlreadyExists_Prompt
  1371. ECHO.&ECHO.
  1372. ECHO ^<!^>       ERROR       ^<!^>
  1373. ECHO %SeparatorLong%
  1374. ECHO.
  1375. ECHO Found an already existing backup archive file!
  1376. ECHO.
  1377. ECHO Options:
  1378. ECHO %SeparatorSmall%
  1379. ECHO [Delete]
  1380. ECHO Any other key will mean 'Cancel'.
  1381. CALL :UserInput
  1382. GOTO :Backup_CheckResources_AlreadyExists_Prompt_UserInput
  1383.  
  1384.  
  1385.  
  1386. REM # =============================================================================================
  1387. REM # Documentation: Inspect the user's input; if they explicitly put "Delete", then the archive file gets expunged and the program will continue, otherwise - we stop.
  1388. REM # =============================================================================================
  1389. :Backup_CheckResources_AlreadyExists_Prompt_UserInput
  1390. IF /I "%STDIN%" EQU "Delete" (
  1391.     CALL :Backup_CheckResources_AlreadyExists_Prompt_Thrash || (CALL :CaughtErrorSignal& EXIT /B 1)
  1392.     EXIT /B 0
  1393. ) ELSE (
  1394.     EXIT /B 1
  1395. )
  1396.  
  1397.  
  1398.  
  1399. REM # =============================================================================================
  1400. REM # Documentation: Delete the archive by user's request
  1401. REM # =============================================================================================
  1402. :Backup_CheckResources_AlreadyExists_Prompt_Thrash
  1403. CALL :Operation_Display_IncomingTaskSubLevelMSG "Removing an already existing archive file [ %Output% ]"
  1404. SET "TaskCaller_NiceProgramName=Delete"
  1405. SET TaskCaller_CallLong=DEL "%Output%"
  1406. CALL :Operation_TaskOperation
  1407. EXIT /B %ExitCode%
  1408.  
  1409.  
  1410.  
  1411.  
  1412. REM =====================================================================
  1413. REM Operations: General Program Use
  1414. REM ----------------------------
  1415. REM Within this block contains frequently used functions for the Backup and Restore process.
  1416. REM =====================================================================
  1417.  
  1418.  
  1419. REM # =============================================================================================
  1420. REM # Documentation: This function will help keep the activity messages in a cleaner standard.
  1421. REM # Parameters:
  1422. REM #   [string] TaskName
  1423. REM # =============================================================================================
  1424. :Operation_Display_IncomingTask
  1425. IF %ToggleLog% EQU True CALL :Operation_Display_IncomingTaskLog "%~1"
  1426. ECHO %~1. . .
  1427. GOTO :EOF
  1428.  
  1429.  
  1430.  
  1431. REM # =============================================================================================
  1432. REM # Documentation: This function will help keep the activity messages in a cleaner standard.
  1433. REM # Parameters:
  1434. REM #   [string] TaskName
  1435. REM # =============================================================================================
  1436. :Operation_Display_IncomingTaskSubLevel
  1437. IF %ToggleLog% EQU True CALL :Operation_Display_IncomingTaskLog "%~1"
  1438. ECHO    %~1. . .
  1439. GOTO :EOF
  1440.  
  1441.  
  1442.  
  1443. REM # =============================================================================================
  1444. REM # Documentation: This function will help keep the activity messages in a cleaner standard.  Messages passed through this function are only treated as standard messages and not fully procedures.
  1445. REM # Parameters:
  1446. REM #   [string] TaskName
  1447. REM # =============================================================================================
  1448. :Operation_Display_IncomingTaskSubLevelMSG
  1449. (ECHO %~1) >> %STDOUT%
  1450. ECHO    %~1
  1451. GOTO :EOF
  1452.  
  1453.  
  1454.  
  1455. REM # =============================================================================================
  1456. REM # Documentation: This function will help keep the log activity messages in a cleaner standard.
  1457. REM # Parameters:
  1458. REM #   [string] TaskName
  1459. REM # =============================================================================================
  1460. :Operation_Display_IncomingTaskLog
  1461. (ECHO Performing Task:) >> %STDOUT%
  1462. (ECHO   %~1) >> %STDOUT%
  1463. (ECHO.) >> %STDOUT%
  1464. (ECHO.) >> %STDOUT%
  1465. GOTO :EOF
  1466.  
  1467.  
  1468.  
  1469. REM # =============================================================================================
  1470. REM # Documentation: Run the operation by invoking the defined variable 'TaskCaller_CallLong'.
  1471. REM # =============================================================================================
  1472. :Operation_TaskOperation
  1473. REM Run the operation that is packaged.
  1474. %TaskCaller_CallLong%>> "%STDOUT%" 2>&1
  1475. SET ExitCode=%ERRORLEVEL%
  1476. REM If we're logging, call the log-footer
  1477. IF %ToggleLog% EQU True CALL :Operation_LogFooter
  1478. GOTO :EOF
  1479.  
  1480.  
  1481.  
  1482. REM # =============================================================================================
  1483. REM # Parameters: [{STRING} File]
  1484. REM # Documentation: Adjacent to the function Operation_TaskOperation, but the output will be redirected to a specific file.
  1485. REM # =============================================================================================
  1486. :Operation_TaskRedirectOperation
  1487. REM Run the operation that is packaged.
  1488. %TaskCaller_CallLong%>> "%~1" 2>&1
  1489. SET ExitCode=%ERRORLEVEL%
  1490. REM If we're logging, call the log-footer
  1491. IF %ToggleLog% EQU True CALL :Operation_LogFooter
  1492. GOTO :EOF
  1493.  
  1494.  
  1495.  
  1496. REM # =============================================================================================
  1497. REM # Documentation: Always print this to log files after executing a task or a program.
  1498. REM # =============================================================================================
  1499. :Operation_LogFooter
  1500. (ECHO.)>> "%STDOUT%"
  1501. (ECHO.)>> "%STDOUT%"
  1502. (ECHO.)>> "%STDOUT%"
  1503. (ECHO.)>> "%STDOUT%"
  1504. (ECHO Program Called:)>> "%STDOUT%"
  1505. (ECHO   %TaskCaller_NiceProgramName%)>> "%STDOUT%"
  1506. (ECHO Task Performed:)>> "%STDOUT%"
  1507. (ECHO   %TaskCaller_CallLong%)>> "%STDOUT%"
  1508. (ECHO Exit Code: %ExitCode%)>> "%STDOUT%"
  1509. (ECHO %Separator%)>> "%STDOUT%"
  1510. (ECHO Time: %Time%   -   Date: %Date%)>> "%STDOUT%"
  1511. (ECHO Project Name: %ProjectName%   -   Module Version: %ProjectVersion%)>> "%STDOUT%"
  1512. (ECHO %SeparatorLong%)>> "%STDOUT%"
  1513. (ECHO %SeparatorLong%)>> "%STDOUT%"
  1514. (ECHO.)>> "%STDOUT%"
  1515. (ECHO.)>> "%STDOUT%"
  1516. GOTO :EOF
  1517.  
  1518.  
  1519.  
  1520. REM # =============================================================================================
  1521. REM # Documentation: Always print this to logfiles after a driver finished executing.
  1522. REM # Parameters: [{String} DriverMainProcess]
  1523. REM # =============================================================================================
  1524. :Operation_DriverLogFooter
  1525. REM ----
  1526. REM If incase the drivers call this function, opt out when the program is not logging.
  1527. IF %ToggleLog% EQU False (GOTO :EOF)
  1528. REM ----
  1529. (ECHO.)>> "%STDOUT%"
  1530. (ECHO.)>> "%STDOUT%"
  1531. (ECHO.)>> "%STDOUT%"
  1532. (ECHO.)>> "%STDOUT%"
  1533. (ECHO %SeparatorSmall%)>> "%STDOUT%"
  1534. (ECHO %Separator%)>> "%STDOUT%"
  1535. (ECHO Finished Executing Task:)>> "%STDOUT%"
  1536. (ECHO   %~1)>> %STDOUT%
  1537. (ECHO Time: %Time%   -   Date: %Date%)>> "%STDOUT%"
  1538. (ECHO Project Name: %ProjectName%   -   Module Version: %ProjectVersion%)>> "%STDOUT%"
  1539. (ECHO %SeparatorLong%)>> "%STDOUT%"
  1540. (ECHO %SeparatorLong%)>> "%STDOUT%"
  1541. (ECHO %Separator%)>> "%STDOUT%"
  1542. (ECHO %Separator%)>> "%STDOUT%"
  1543. (ECHO %SeparatorLong%)>> "%STDOUT%"
  1544. (ECHO %SeparatorLong%)>> "%STDOUT%"
  1545. (ECHO.)>> "%STDOUT%"
  1546. (ECHO.)>> "%STDOUT%"
  1547. GOTO :EOF
  1548.  
  1549.  
  1550.  
  1551. REM # =============================================================================================
  1552. REM # Documentation: Cautionary note; the user should never close this program prematurely.
  1553. REM # =============================================================================================
  1554. :Operation_DisplayHeaderMessage
  1555. REM Just display text on the terminal
  1556. ECHO ^<i^>       Important       ^<i^>
  1557. ECHO Terminating this program prematurely can cause either hanging or zombie processes, in case can either hog the system's resources for an extended amount of time or will never terminate.
  1558. ECHO.
  1559. ECHO The operation might take several hours, please be patient!
  1560. ECHO.&ECHO.
  1561. GOTO :EOF
  1562.  
  1563.  
  1564.  
  1565. REM # =============================================================================================
  1566. REM # Documentation: For programs that uses reverse of the standard return code, this function will reverse them back to normal so the program will understand how to to properly treat the return value.
  1567. REM # =============================================================================================
  1568. :Operation_FlipBit_Common
  1569. IF %1 EQU 1 (
  1570.    REM 1 = Successful Operation
  1571.     EXIT /B 0
  1572. ) ELSE (
  1573.    REM Failure or something else
  1574.     EXIT /B 1
  1575. )
  1576.  
  1577.  
  1578.  
  1579. REM =====================================================
  1580. REM -----------------------------------------------------
  1581. REM =====================================================
  1582.  
  1583.  
  1584.  
  1585.  
  1586. REM # =============================================================================================
  1587. REM # Documentation: An error occurred during the operation.
  1588. REM # =============================================================================================
  1589. :Operation_TerminateWithError
  1590. IF %UseBell% GEQ 1 ECHO %SND_BELL%& ECHO %SND_BELL%
  1591. ECHO ^<!!!^>       FATAL ERROR       ^<!!!^>
  1592. ECHO %SeparatorLong%
  1593. ECHO.
  1594. ECHO An error occurred during the operation!
  1595. REM If the user is logging, tell them where they can find the logs
  1596. IF %ToggleLog% EQU True (
  1597.     ECHO Check the log for more information about the error.
  1598.     ECHO Log Directory:
  1599.     ECHO   %LocalDirectory.Logs%
  1600.     ECHO Log Name:
  1601.     ECHO   %STDOUT%
  1602. )
  1603. GOTO :EOF
  1604.  
  1605.  
  1606.  
  1607. REM # =============================================================================================
  1608. REM # Documentation: Everything was backed up or restored successfully.
  1609. REM # =============================================================================================
  1610. :Operation_TerminateSuccessfully
  1611. IF %UseBell% EQU 1 ECHO %SND_BELL%
  1612. ECHO ^<-^>       Operation Successful       ^<-^>
  1613. ECHO %SeparatorLong%
  1614. ECHO.
  1615. ECHO Operation was successful!
  1616. GOTO :EOF
  1617.  
  1618.  
  1619.  
  1620.  
  1621. REM =====================================================================
  1622. REM Power State
  1623. REM ----------------------------
  1624. REM This section will manage the Power State.  When the initial operation has been successfully completed, the program can be able
  1625. REM     to send a signal to the Operating System to enter into a energy saving state that uses - obviously - less power.
  1626. REM     This is completely changeable by the user within the program's control panel; this has no effect to the Operating System's standard power settings.
  1627. REM =====================================================================
  1628.  
  1629.  
  1630.  
  1631. REM # =============================================================================================
  1632. REM # Documentation: This function will check the user's power state settings and execute the member function that issues the execution.
  1633. REM # =============================================================================================
  1634. :PowerState
  1635. REM Disabled
  1636. IF "%UserConfig.PowerState%" EQU "0" (
  1637.     CALL :PowerState_DoNothing
  1638.     GOTO :EOF
  1639. )
  1640.  
  1641. REM Suspend
  1642. IF "%UserConfig.PowerState%" EQU "1" (
  1643.     CALL :PowerState_SignalSuspend
  1644.     GOTO :EOF
  1645. )
  1646.  
  1647. REM Hibernation
  1648. IF "%UserConfig.PowerState%" EQU "2" (
  1649.     CALL :PowerState_SignalHibernation
  1650.     GOTO :EOF
  1651. )
  1652.  
  1653. REM Shutdown
  1654. IF "%UserConfig.PowerState%" EQU "3" (
  1655.     CALL :PowerState_SignalShutdown
  1656.     GOTO :EOF
  1657. ) ELSE (
  1658.    REM Bad value; unknown Power State
  1659.     CALL :PowerState_BadValue
  1660.     GOTO :EOF
  1661. )
  1662.  
  1663.  
  1664.  
  1665. REM # =============================================================================================
  1666. REM # Documentation: When called, this will manage the PowerState when set to 'disabled'
  1667. REM # =============================================================================================
  1668. :PowerState_DoNothing
  1669. CALL :PowerState_DisplayMessage "disabled; skipping" 0
  1670. GOTO :EOF
  1671.  
  1672.  
  1673.  
  1674. REM # =============================================================================================
  1675. REM # Documentation: When called, this will manage the PowerState when set to 'Suspend'
  1676. REM # =============================================================================================
  1677. :PowerState_SignalSuspend
  1678. CALL :PowerState_DisplayMessage "Suspend" 1
  1679. REM ----
  1680. Rundll32.exe Powrprof.dll,SetSuspendState Sleep
  1681. REM ----
  1682. GOTO :EOF
  1683.  
  1684.  
  1685.  
  1686. REM # =============================================================================================
  1687. REM # Documentation: When called, this will manage the PowerState when set to 'Hibernation'
  1688. REM # =============================================================================================
  1689. :PowerState_SignalHibernation
  1690. CALL :PowerState_DisplayMessage "Hibernation" 1
  1691. REM ----
  1692. SHUTDOWN /f /h
  1693. REM ----
  1694. GOTO :EOF
  1695.  
  1696.  
  1697.  
  1698. REM # =============================================================================================
  1699. REM # Documentation: When called, this will manage the PowerState when set to 'Shutdown'
  1700. REM # =============================================================================================
  1701. :PowerState_SignalShutdown
  1702. CALL :PowerState_DisplayMessage "Shutdown" 1
  1703. CALL :PowerState_AbortSignal
  1704. REM ----
  1705. SHUTDOWN /f /t %UserConfig.PowerStateGraceTime% /s
  1706. REM ----
  1707. GOTO :EOF
  1708.  
  1709.  
  1710.  
  1711. REM # =============================================================================================
  1712. REM # Documentation: When called, this will only notify the user that the value for the Power State is unknown.
  1713. REM # =============================================================================================
  1714. :PowerState_BadValue
  1715. CALL :PowerState_DisplayMessage "UNKNOWN_VALUE" 0
  1716. GOTO :EOF
  1717.  
  1718.  
  1719.  
  1720. REM # =============================================================================================
  1721. REM # Parameters: [{String} PowerState Mode]
  1722. REM # Documentation: This function will display (and even log) what power state is being issued.
  1723. REM # =============================================================================================
  1724. :PowerState_DisplayMessage
  1725. REM Display that we're starting the backup process
  1726. SET "DriversNiceTask=Power State: %~1"
  1727. CALL :Operation_Display_IncomingTask "%DriversNiceTask%"
  1728.  
  1729. REM If the signal is being sent to the OS, tell the user (and or log it)
  1730. IF %~2 EQU 1 (
  1731.     CALL :Operation_Display_IncomingTaskSubLevel "Sending signal..."
  1732. )
  1733. GOTO :EOF
  1734.  
  1735.  
  1736.  
  1737. REM # =============================================================================================
  1738. REM # Documentation: This method will merely output instructions on how to abort the shutdown grace period.
  1739. REM # =============================================================================================
  1740. :PowerState_AbortSignal
  1741. ECHO.
  1742. ECHO ABORT THE COUNT-DOWN INSTRUCTIONS
  1743. ECHO ---------------------------------------
  1744. ECHO.
  1745. ECHO Go to Windows PowerShell or Windows Command (use the search on the Windows Start Menu or Start Screen)
  1746. ECHO Type the following into the terminal:
  1747. ECHO    SHUTDOWN /A
  1748. ECHO This command with the 'A' switch will abort the count-down and the system will continue to run as is.
  1749. ECHO.
  1750. GOTO :EOF
  1751.  
  1752.  
  1753.  
  1754.  
  1755. REM =====================================================================
  1756. REM Check for Updates
  1757. REM ----------------------------
  1758. REM To make things for the end-user, this allows the user to quickly check for available updates with ease.  Despite there's limitations with Batch, we can not really automatically fetch information and append them.  However, instead, this will open Windows Explorer's functionality to open website pages.  This functionality alone will help the user to determine if there is new updates or if the module that they currently have is still the current latest version.
  1759. REM =====================================================================
  1760.  
  1761.  
  1762. REM # =============================================================================================
  1763. REM # Documentation: This function is a small driver for checking updates.
  1764. REM # =============================================================================================
  1765. :ModuleUpdates
  1766. CALL :DashboardOrClassicalDisplay
  1767. CALL :ModuleUpdates_InternalInformation
  1768. CALL :ModuleUpdates_OpenWeb
  1769. PAUSE
  1770. GOTO :EOF
  1771.  
  1772.  
  1773.  
  1774. REM # =============================================================================================
  1775. REM # Documentation: This will display all of the information necessary to help the user determine if the module is up to date or is outdated.
  1776. REM # =============================================================================================
  1777. :ModuleUpdates_InternalInformation
  1778. ECHO Current Module Information:
  1779. ECHO %Separator%
  1780. ECHO Project:
  1781. ECHO    %ProjectName%
  1782. ECHO Version:
  1783. ECHO    %ProjectVersion%
  1784. ECHO Released:
  1785. ECHO    %ReleaseDate%
  1786. ECHO.&ECHO.
  1787. GOTO :EOF
  1788.  
  1789.  
  1790.  
  1791. REM # =============================================================================================
  1792. REM # Documentation: This function will call Windows Explorer - regardless of the CallExplorer variable from the core -, and go to an official website or forum that will contain information and resources of newer updates and recent changes.
  1793. REM # =============================================================================================
  1794. :ModuleUpdates_OpenWeb
  1795. CALL :Call_WindowsExplorer "http://forum.drdteam.org/viewtopic.php?p=53914#p53914"
  1796. GOTO :EOF
  1797.  
  1798.  
  1799.  
  1800.  
  1801. REM =====================================================================
  1802. REM Settings Menu
  1803. REM ----------------------------
  1804. REM This allows the user to manipulate some settings that is available in this module script.
  1805. REM =====================================================================
  1806.  
  1807.  
  1808. REM # =============================================================================================
  1809. REM # Documentation: Main Control Panel
  1810. REM # =============================================================================================
  1811. :Settings
  1812. CALL :DashboardOrClassicalDisplay
  1813. CALL :QuoteDatabase
  1814. ECHO Control Panel
  1815. ECHO %Separator%
  1816. ECHO.
  1817. ECHO [1] Encrypt Backup Compact Files with Password
  1818. ECHO     When set to 'True', this will allow the program encrypt the compact data with a password that was set within the 'Bootless Star' configuration.
  1819. ECHO     - Current Value: [%UserConfig.7ZipUseKey%]
  1820. ECHO.
  1821. ECHO [2] Back to the Future Quotes
  1822. ECHO     When set to 'True', this will allow the program display quotes from the movie 'Back to the Future'.
  1823. ECHO     - Current Value: [%UserConfig.BackToTheFutureQuotes%]
  1824. ECHO.
  1825. ECHO [3] Change Local Directory Location
  1826. ECHO     This allows the ability to change the %ProjectName%'s Local Directory current destination to another specific location.  Ideally, this should be used on a dedicated secondary storage [HDD preferred] that is only used for system backups.
  1827. ECHO     NOTE: This will NOT transition the current data that is stored within the local directories to the new destination!
  1828. ECHO     - Current Value: [%LocalDirectory.MainRoot%]
  1829. ECHO.
  1830. ECHO [4] Exclude Videos from Backup
  1831. ECHO     When set to 'True', this will forbid the program from backing up the user's Videos.
  1832. ECHO         Directories that will be excluded: ~\Videos, ~\My Videos, ~\Movies, ~\My Movies
  1833. ECHO     - Current Value: [%UserConfig.ExcludeVideos%]
  1834. ECHO.
  1835. ECHO [5] Toggle System's Power State
  1836. ECHO     After the user's settings has been backed up successfully, the program can issue a signal to the Operating System to enter a Sleep state, a full Hibernation state, or shutdown the system.
  1837. ECHO     NOTE: By default, this is disabled.
  1838. REM The variable must be translated into a form that the user can understand
  1839. CALL :Settings_NiceValues_PowerState
  1840. REM ----
  1841. ECHO     - Current Value: [%ProcessVarA%]
  1842. ECHO.
  1843. ECHO Other Options
  1844. ECHO %SeparatorSmall%
  1845. ECHO [U] Update Saved Profile named: %UserConfigurationLoaded%
  1846. ECHO [X] Exit
  1847. CALL :UserInput
  1848. GOTO :Settings_UserInput
  1849.  
  1850.  
  1851.  
  1852. REM # =============================================================================================
  1853. REM # Documentation: Inspect the users input.
  1854. REM # =============================================================================================
  1855. :Settings_UserInput
  1856. IF "%STDIN%" EQU "1" GOTO :Settings_Toggle_EncryptKey
  1857. IF "%STDIN%" EQU "2" GOTO :Settings_Toggle_BackToTheFutureQuotes
  1858. IF "%STDIN%" EQU "3" GOTO :Settings_Update_LocalDirectory
  1859. IF "%STDIN%" EQU "4" GOTO :Settings_Toggle_ExcludeVideosBackup
  1860. IF "%STDIN%" EQU "5" GOTO :Settings_Update_PowerState
  1861. IF /I "%STDIN%" EQU "U" GOTO :Settings_UpdateProfile
  1862. IF /I "%STDIN%" EQU "X" GOTO :EOF
  1863. IF /I "%STDIN%" EQU "Exit" GOTO :EOF
  1864. CALL :BadInput& GOTO :Settings
  1865.  
  1866.  
  1867.  
  1868. REM # =============================================================================================
  1869. REM # Documentation: Allow the program to encrypt the archives with a password that was defined from the environment program?
  1870. REM # =============================================================================================
  1871. :Settings_Toggle_EncryptKey
  1872. IF %UserConfig.7ZipUseKey% EQU True (
  1873.     SET UserConfig.7ZipUseKey=False
  1874. ) ELSE (
  1875.     SET UserConfig.7ZipUseKey=True
  1876. )
  1877. CALL :ClearBuffer
  1878. GOTO :Settings
  1879.  
  1880.  
  1881.  
  1882. REM # =============================================================================================
  1883. REM # Documentation: Allow the program to display Back to the Future movie quotes?
  1884. REM # =============================================================================================
  1885. :Settings_Toggle_BackToTheFutureQuotes
  1886. IF %UserConfig.BackToTheFutureQuotes% EQU True (
  1887.     SET UserConfig.BackToTheFutureQuotes=False
  1888. ) ELSE (
  1889.     SET UserConfig.BackToTheFutureQuotes=True
  1890. )
  1891. CALL :ClearBuffer
  1892. GOTO :Settings
  1893.  
  1894.  
  1895.  
  1896. REM # =============================================================================================
  1897. REM # Documentation: Allow the program to exclude the users typical video directories from backup.
  1898. REM # =============================================================================================
  1899. :Settings_Toggle_ExcludeVideosBackup
  1900. IF %UserConfig.ExcludeVideos% EQU True (
  1901.     SET UserConfig.ExcludeVideos=False
  1902. ) ELSE (
  1903.     SET UserConfig.ExcludeVideos=True
  1904. )
  1905. CALL :ClearBuffer
  1906. GOTO :Settings
  1907.  
  1908.  
  1909.  
  1910. REM # =============================================================================================
  1911. REM # Documentation: User Configuration Settings
  1912. REM # =============================================================================================
  1913. :Settings_UpdateProfile
  1914. CALL :ClearBuffer
  1915. CALL :UserPreset_Driver 1
  1916. CALL :ClearBuffer
  1917. GOTO :Settings
  1918.  
  1919.  
  1920.  
  1921. REM # =============================================================================================
  1922. REM # Documentation: Allow the user to update the program's Local Directory to a new destination.  This will be helpful to allow the user to keep the backups to a specific HDD.
  1923. REM # =============================================================================================
  1924. :Settings_Update_LocalDirectory
  1925. CLS
  1926. CALL :DashboardOrClassicalDisplay
  1927. CALL :QuoteDatabase
  1928. ECHO Control Panel: Update Local Directory Location
  1929. ECHO %Separator%
  1930. ECHO.
  1931. ECHO This allows the ability to change the %ProjectName%'s Local Directory current destination to another specific location.  Ideally, this should be used on a dedicated secondary storage [Hard Drive preferred] that is only used for system backups.  But, however, after a new location has been defined, this program will _NOT_ transition the current data that is stored within the local directories to the new destination!
  1932. ECHO.
  1933. ECHO Current Location:
  1934. ECHO    %LocalDirectory.MainRoot%
  1935. ECHO.
  1936. ECHO Define a new location:
  1937. ECHO.
  1938. ECHO.
  1939. ECHO Other Options
  1940. ECHO %SeparatorSmall%
  1941. ECHO [Cancel] [Restore]
  1942. CALL :UserInput
  1943. GOTO :Settings_Update_LocalDirectory_UserInput
  1944.  
  1945.  
  1946.  
  1947. REM # =============================================================================================
  1948. REM # Documentation: Inspect the users decision about updating the local directory location
  1949. REM # =============================================================================================
  1950. :Settings_Update_LocalDirectory_UserInput
  1951. IF /I "%STDIN%" EQU "Cancel" (
  1952.     CALL :ClearBuffer
  1953.     GOTO :Settings
  1954. )
  1955. IF /I "%STDIN%" EQU "Restore" (
  1956.    REM We do NOT need to 'create' the directories, as the program will do this anyways at the start-up protocol.
  1957.     CALL :Initialization_Driver RestoreLocalDirectoryLocation
  1958.     CALL :ClearBuffer
  1959.     GOTO :Settings
  1960. ) ELSE (
  1961.     CALL :Settings_Update_LocalDirectory_UserInput_Validate
  1962.     CALL :ClearBuffer
  1963.     GOTO :Settings
  1964. )
  1965.  
  1966.  
  1967.  
  1968. REM # =============================================================================================
  1969. REM # Documentation: Update the local directory location protocol
  1970. REM # =============================================================================================
  1971. :Settings_Update_LocalDirectory_UserInput_Validate
  1972. REM Clean the user's input from trailing slashes
  1973. CALL :Settings_Update_LocalDirectory_UserInput_Validate_CleanSTDIN
  1974. REM Store the value in a working var -- mainly a work around for pushing errors with parameters
  1975. SET "ProcessVarA=%STDIN%"
  1976. REM Does the path actually exists?  If not, opt-out immediately
  1977. CALL :Settings_Update_LocalDirectory_UserInput_Validate_CheckExists || (CALL :Settings_Update_LocalDirectory_UserInput_Validate_CheckExistsErr& EXIT /B 1)
  1978. REM ----
  1979. REM -------  Changes
  1980. REM Update the Local Directory identifiers
  1981. CALL :Initialization_Driver UpdateLocalDirectoryLocation "%ProcessVarA%"
  1982. REM Create the new local directories at the specified location
  1983. CALL :Prerequisite_Driver || (CALL :Initialization_Driver RestoreLocalDirectoryLocation& EXIT /B 1)
  1984. REM -------
  1985. REM ----
  1986. EXIT /B 1
  1987.  
  1988.  
  1989.  
  1990.  
  1991. REM # =============================================================================================
  1992. REM # Documentation: Filter any trailing back-slashes from the STDIN.
  1993. REM # =============================================================================================
  1994. :Settings_Update_LocalDirectory_UserInput_Validate_CleanSTDIN
  1995. REM Using the variable value, read the last character from the value.  -1 == One character from the right side
  1996. IF "%STDIN:~-1%" EQU "\" (
  1997.    REM Select the range, the -1 means we are limiting the right side; we're effectively dropping 'one' character.
  1998.     SET "STDIN=%STDIN:~0,-1%"
  1999. ) ELSE (
  2000.     GOTO :EOF
  2001. )
  2002. REM If incase the user adds more of the back slashes for whatever reason, call the function again until it is fixed.
  2003. GOTO :Settings_Update_LocalDirectory_UserInput_Validate_CleanSTDIN
  2004.  
  2005.  
  2006.  
  2007. REM # =============================================================================================
  2008. REM # Parameters: [{String} DirectoryPath]
  2009. REM # Documentation: Check if the destination path exists
  2010. REM # =============================================================================================
  2011. :Settings_Update_LocalDirectory_UserInput_Validate_CheckExists
  2012. IF EXIST "%ProcessVarA%" (
  2013.    REM It exists, return a 0
  2014.     EXIT /B 0
  2015. ) ELSE (
  2016.    REM return an error signal
  2017.     EXIT /B 1
  2018. )
  2019.  
  2020.  
  2021.  
  2022. REM # =============================================================================================
  2023. REM # Parameters: [{String} DirectoryPath]
  2024. REM # Documentation: Error Message when the Check Exists sends an error signal
  2025. REM # =============================================================================================
  2026. :Settings_Update_LocalDirectory_UserInput_Validate_CheckExistsErr
  2027. ECHO !ERR!: The specified path "%ProcessVarA%" does not exists!
  2028. PAUSE
  2029. GOTO :EOF
  2030.  
  2031.  
  2032.  
  2033. REM # =============================================================================================
  2034. REM # Documentation: Inspect the value of the Power State variable (which is an Integer value) and
  2035. REM #           translate it to string that the user can easily understand.
  2036. REM # =============================================================================================
  2037. :Settings_NiceValues_PowerState
  2038. IF "%UserConfig.PowerState%" EQU "0" (
  2039.     SET "ProcessVarA=Disabled"
  2040.     GOTO :EOF
  2041. )
  2042. IF "%UserConfig.PowerState%" EQU "1" (
  2043.     SET "ProcessVarA=Suspend Mode"
  2044.     GOTO :EOF
  2045. )
  2046. IF "%UserConfig.PowerState%" EQU "2" (
  2047.     SET "ProcessVarA=Hibernation Mode"
  2048.     GOTO :EOF
  2049. )
  2050. IF "%UserConfig.PowerState%" EQU "3" (
  2051.     SET "ProcessVarA=Shutdown"
  2052.     GOTO :EOF
  2053. ) ELSE (
  2054.     SET "ProcessVarA=!CRIT_ERR!: Couldn't translate variable 'PowerState' of value [%UserConfig.PowerState%]!"
  2055. )
  2056. EXIT /B 1
  2057.  
  2058.  
  2059.  
  2060. REM # =============================================================================================
  2061. REM # Documentation: This function will allow the user to change the power settings within this program.
  2062. REM #       Obviously this has ABSOLUTELY NO RELATION to the local system's power settings that the OS itself manages.
  2063. REM #       Instead, this program will issue a signal to either sleep, shutdown, or hibernate.
  2064. REM # =============================================================================================
  2065. :Settings_Update_PowerState
  2066. CLS
  2067. CALL :DashboardOrClassicalDisplay
  2068. CALL :QuoteDatabase
  2069. ECHO Control Panel: Update Power Settings
  2070. ECHO %Separator%
  2071. ECHO.
  2072. ECHO.
  2073. ECHO Power Settings:
  2074. ECHO -----------------
  2075. ECHO Once the backup has been completed, this program can send a signal to the Operating System to enter into a energy saving power state.  There will be a %UserConfig.PowerStateGraceTime% minute grace period - in which the user can abort the process, but only for commands that support this grace time.
  2076. ECHO CRITICAL NOTE: the 'force' flag WILL be used in the signal!
  2077. ECHO.
  2078. ECHO Currently Set:
  2079. CALL :Settings_NiceValues_PowerState
  2080. ECHO   %ProcessVarA%
  2081. ECHO.
  2082. ECHO [1] Keep System Powered On
  2083. ECHO       The computer will remain as-is; the Operating System power setting's will still manage the idle state.0
  2084. ECHO.
  2085. ECHO [2] Suspend State
  2086. ECHO       Place the system into sleep mode as soon as the %ProjectName% finishes it's backup process.
  2087. ECHO       No grace time will be issued
  2088. ECHO.
  2089. ECHO [3] Hibernation State
  2090. ECHO       Place the entire system into hibernation mode as soon as the %ProjectName% finishes it's backup process.
  2091. ECHO.
  2092. ECHO [4] Shutdown System
  2093. ECHO       Completely shutdown the entire system as soon as the %ProjectName% finishes it's backup process.
  2094. ECHO      NOTE for WINDOWS 8 and LATER PC USERS
  2095. ECHO            With the 'force' flag being used, the Kernel state will be thrashed.  Meaning, that the OS will have a slower start-up time.  During normal operations, the kernel is cached for a faster start-up.
  2096. ECHO.
  2097. ECHO.
  2098. ECHO Other Options
  2099. ECHO %SeparatorSmall%
  2100. ECHO [X] Cancel
  2101. CALL :UserInput
  2102. GOTO :Settings_Update_PowerState_UserInput
  2103.  
  2104.  
  2105.  
  2106. REM # =============================================================================================
  2107. REM # Documentation: Update the Power Setting's based on the user's feedback.
  2108. REM # =============================================================================================
  2109. :Settings_Update_PowerState_UserInput
  2110. REM Cancel \ Go back to the previous menu
  2111. IF /I "%STDIN%" EQU "X" (
  2112.     CALL :ClearBuffer
  2113.     GOTO :Settings
  2114. )
  2115. IF /I "%STDIN%" EQU "Cancel" (
  2116.     CALL :ClearBuffer
  2117.     GOTO :Settings
  2118. )
  2119. IF /I "%STDIN%" EQU "Exit" (
  2120.     CALL :ClearBuffer
  2121.     GOTO :Settings
  2122. )
  2123. REM ----
  2124.  
  2125. REM Keep Running; disabled energy saving states
  2126. IF "%STDIN%" EQU "1" (
  2127.     SET UserConfig.PowerState=0
  2128.     CALL :ClearBuffer
  2129.     GOTO :Settings
  2130. )
  2131.  
  2132. REM Suspend Power State
  2133. IF "%STDIN%" EQU "2" (
  2134.     SET UserConfig.PowerState=1
  2135.     CALL :ClearBuffer
  2136.     GOTO :Settings
  2137. )
  2138.  
  2139. REM Hibernation Power State
  2140. IF "%STDIN%" EQU "3" (
  2141.     SET UserConfig.PowerState=2
  2142.     CALL :ClearBuffer
  2143.     GOTO :Settings
  2144. )
  2145.  
  2146. REM Shutdown System
  2147. IF "%STDIN%" EQU "4" (
  2148.     SET UserConfig.PowerState=3
  2149.     CALL :ClearBuffer
  2150.     GOTO :Settings
  2151. ) ELSE (
  2152.    REM Incorrect or invalid input
  2153.     CALL :BadInput& GOTO :Settings_Update_PowerState
  2154. )
  2155.  
  2156.  
  2157.  
  2158.  
  2159. REM =====================================================================
  2160. REM User Configuration [Key Chain]
  2161. REM ----------------------------
  2162. REM This allows the user to effectively to update, create, and load their own configuration presets.
  2163. REM
  2164. REM This is compatible with Bootless Star's 1.2 Key Chain Model
  2165. REM =====================================================================
  2166.  
  2167.  
  2168. REM # =============================================================================================
  2169. REM # Parameters: [{int} Mode]
  2170. REM # Documentation: This driver function assures that the users configuration file is either loaded or saved properly.
  2171. REM # =============================================================================================
  2172. :UserPreset_Driver
  2173. REM First, check to make sure that we're not using the coreDefault configuration.  If the user is using the default, then opt out of this driver -- we can not use this feature.
  2174. IF %UserConfigurationKeyChainToken% EQU 0 EXIT /B 1
  2175.  
  2176. REM Cache the filename to a variable - for simplicity.
  2177. CALL :UserPreset_CacheFileName
  2178.  
  2179. REM Check the parameters and determine how to execute.
  2180. IF %1 EQU 0 CALL :UserPreset_Load "%ProcessVarA%"
  2181. IF %1 EQU 1 CALL :UserPreset_Update "%ProcessVarA%"
  2182. IF %1 EQU 2 CALL :UserPreset_Create "%ProcessVarA%"
  2183. REM Successful operation
  2184. EXIT /B 0
  2185.  
  2186.  
  2187.  
  2188. REM # =============================================================================================
  2189. REM # Documentation: Cache the filename to a variable - for simplicity.
  2190. REM # =============================================================================================
  2191. :UserPreset_CacheFileName
  2192. SET "ProcessVarA=%LocalDirectory.UserConfig%\%UserConfigurationKeyChainToken%.bat"
  2193. GOTO :EOF
  2194.  
  2195.  
  2196.  
  2197. REM # =============================================================================================
  2198. REM # Parameters: [{String} File]
  2199. REM # Documentation: Load the preset configuration file.
  2200. REM # =============================================================================================
  2201. :UserPreset_Load
  2202. IF EXIST "%~1" (
  2203.     CALL "%~1"
  2204.    REM Run through the Local Directory protocol
  2205.     CALL :UserPreset_Load_LocalDirectoryProtocol
  2206. )
  2207. GOTO :EOF
  2208.  
  2209.  
  2210.  
  2211. REM # =============================================================================================
  2212. REM # Documentation: Besure that the local directories exists within the specified paths; if not - revert to default to avoid errors.
  2213. REM # =============================================================================================
  2214. :UserPreset_Load_LocalDirectoryProtocol
  2215. IF EXIST "%LocalDirectory.MainRoot%" (
  2216.    REM Detected; no problems
  2217.     CALL :Initialization_Driver UpdateLocalDirectorySubLocation
  2218.     EXIT /B 0
  2219. ) ELSE (
  2220.     CALL :UserPreset_Load_LocalDirectoryProtocol_FaultMSG
  2221.     CALL :Initialization_Driver RestoreLocalDirectoryLocation
  2222.     CALL :ClearBuffer
  2223.     EXIT /B 1
  2224. )
  2225.  
  2226.  
  2227.  
  2228. REM # =============================================================================================
  2229. REM # Documentation: If the Local Directory location does NOT exist within the specified filesystem or path, then display that the program is using the default location.
  2230. REM # =============================================================================================
  2231. :UserPreset_Load_LocalDirectoryProtocol_FaultMSG
  2232. ECHO.
  2233. ECHO ATTN: The program could not find the local directories at [ %LocalDirectory.MainRoot% ]!  Using default instead...
  2234. PAUSE
  2235. GOTO :EOF
  2236.  
  2237.  
  2238.  
  2239. REM # =============================================================================================
  2240. REM # Parameters: [{String} File]
  2241. REM # Documentation: Update the configuration file with newer settings.
  2242. REM # =============================================================================================
  2243. :UserPreset_Update
  2244. CALL :UserPreset_Create "%~1"
  2245. GOTO :EOF
  2246.  
  2247.  
  2248.  
  2249. REM # =============================================================================================
  2250. REM # Parameters: [{String} File]
  2251. REM # Documentation: Create a new configuration file for this module.  This function is designed to create a new preset script file.  If in case a preset exists, this will automatically thrash it and write a new file within the filesystem.
  2252. REM # =============================================================================================
  2253. :UserPreset_Create
  2254. CALL :UserPreset_MakeFile_Header "%~1"
  2255. CALL :Initialization_Driver SaveUserConfig "%~1"
  2256. CALL :UserPreset_MakeFile_Footer "%~1"
  2257. GOTO :EOF
  2258.  
  2259.  
  2260.  
  2261. REM # =============================================================================================
  2262. REM # Parameters: [{String} File]
  2263. REM # Documentation: This function will create a header for the configuration file; this supplies identity of the file.
  2264. REM # =============================================================================================
  2265. :UserPreset_MakeFile_Header
  2266. (ECHO REM Preset Configuration File)> "%~1"
  2267. (ECHO REM %ProjectName% version %ProjectVersion%)>> "%~1"
  2268. (ECHO REM Created on: %DATE% - %TIME%)>> "%~1"
  2269. (ECHO REM Filename: %UserConfigurationLoaded% - Key Chain: %UserConfigurationKeyChainToken%)>> "%~1"
  2270. (ECHO REM %SeparatorLong%)>> "%~1"
  2271. (ECHO.)>> "%~1"
  2272. GOTO :EOF
  2273.  
  2274.  
  2275.  
  2276. REM # =============================================================================================
  2277. REM # Parameters: [{String} File]
  2278. REM # Documentation: This function will create a footer for the configuration file.
  2279. REM # =============================================================================================
  2280. :UserPreset_MakeFile_Footer
  2281. (ECHO GOTO :EOF)>> "%~1"
  2282. GOTO :EOF
  2283.  
  2284.  
  2285.  
  2286.  
  2287. REM =====================================================================
  2288. REM Back to the Future Quotes Database Manager
  2289. REM ----------------------------
  2290. REM This block contains quotes from the movie Back to the Future [1-3] and will randomly print on the screen.  Why call the program the 'DeLorean' and not have Back to the Future quotes?!  That's just crazy!
  2291. REM =====================================================================
  2292.  
  2293.  
  2294. REM # =============================================================================================
  2295. REM # Documentation: Quote Database Driver
  2296. REM # =============================================================================================
  2297. :QuoteDatabase
  2298. REM Does the user want the quotes to be even displayed on the terminal buffer screen?
  2299. IF %UserConfig.BackToTheFutureQuotes% EQU False GOTO :EOF
  2300. REM Fetch a random number
  2301. CALL :QuoteDatabase_RandNum
  2302. REM Scan through the registry and output a quote
  2303. CALL :QuoteDatabase_ScanQuotes %ERRORLEVEL%
  2304. REM Separate the quote from rest of the programs output.
  2305. CALL :QuoteDatabase_Footer
  2306. GOTO :EOF
  2307.  
  2308.  
  2309.  
  2310. REM # =============================================================================================
  2311. REM # Documentation: Leave additional spaces after the quote has been printed on the screen.
  2312. REM # =============================================================================================
  2313. :QuoteDatabase_Footer
  2314. ECHO.& ECHO.
  2315. GOTO :EOF
  2316.  
  2317.  
  2318.  
  2319. REM # =============================================================================================
  2320. REM # Documentation: Fetch a number within a specific range and return the value.
  2321. REM # =============================================================================================
  2322. :QuoteDatabase_RandNum
  2323. SET /A ProcessVarA=%RANDOM% %% 42
  2324. EXIT /B %ProcessVarA%
  2325.  
  2326.  
  2327.  
  2328. REM # =============================================================================================
  2329. REM # Parameters: [{int} RandomNum]
  2330. REM # Documentation: Using the random number, scan through the quote database and print the quote on the terminal buffer.
  2331. REM #   I am sorry, there's no switch statement in Batch and I wont use a for-loop [assuming that is remotely possible]....
  2332. REM #
  2333. REM #  Quotes Resources:
  2334. REM #    IMDb
  2335. REM #      http://www.imdb.com/title/tt0088763/quotes
  2336. REM #      http://www.imdb.com/title/tt0096874/quotes
  2337. REM #      http://www.imdb.com/title/tt0099088/quotes
  2338. REM # =============================================================================================
  2339. :QuoteDatabase_ScanQuotes
  2340. IF %1 EQU 0 (
  2341.     ECHO Marty McFly: Wait a minute, Doc. Ah... Are you telling me that you built a time machine... out of a DeLorean?
  2342.     ECHO Dr. Emmett Brown: The way I see it, if you're gonna build a time machine into a car, why not do it with some style?
  2343.     GOTO :EOF
  2344. )
  2345.  
  2346. IF %1 EQU 1 (
  2347.     ECHO Dr. Emmett Brown: If my calculations are correct, when this baby hits 88 miles per hour... you're gonna see some serious shit.
  2348.     GOTO :EOF
  2349. )
  2350.  
  2351. IF %1 EQU 2 (
  2352.     ECHO Marty McFly: Hey, Doc, we better back up. We don't have enough road to get up to 88.
  2353.     ECHO Dr. Emmett Brown: Roads? Where we're going, we don't need roads.
  2354.     GOTO :EOF
  2355. )
  2356.  
  2357. IF %1 EQU 3 (
  2358.     ECHO Dr. Emmett Brown: Great Scott!
  2359.     GOTO :EOF
  2360. )
  2361.  
  2362. IF %1 EQU 4 (
  2363.     ECHO Marty McFly: This is heavy.
  2364.     GOTO :EOF
  2365. )
  2366.  
  2367. IF %1 EQU 5 (
  2368.     ECHO Biff Tannen: Since you're new here, I-I'm gonna cut you a break, today. So, why don't you make like a tree and get outta here?
  2369.     GOTO :EOF
  2370. )
  2371.  
  2372. IF %1 EQU 6 (
  2373.     ECHO Younger Dr. Emmett Brown: 1.21 gigawatts! 1.21 gigawatts. Great Scott!
  2374.     ECHO Marty McFly: What-what the hell is a gigawatt?
  2375.     GOTO :EOF
  2376. )
  2377.  
  2378. IF %1 EQU 7 (
  2379.     ECHO Dr. Emmett Brown: [looks at his watch] Damn! Where is that kid?
  2380.     ECHO  [looks at a small alarm clock in his other hand]
  2381.     ECHO Dr. Emmett Brown: Damn!
  2382.     ECHO  [looks at a second watch on his other wrist]
  2383.     ECHO Dr. Emmett Brown: Damn! Damn!
  2384.     GOTO :EOF
  2385. )
  2386.  
  2387. IF %1 EQU 8 (
  2388.     ECHO George McFly: Last night, Darth Vader came down from Planet Vulcan and told me that if I didn't take Lorraine out, that he'd melt my brain.
  2389.     GOTO :EOF
  2390. )
  2391.  
  2392. IF %1 EQU 9 (
  2393.     ECHO Dr. Emmett Brown: I'm sure that in 1985, plutonium is available in every corner drugstore, but in 1955, it's a little hard to come by.
  2394.     GOTO :EOF
  2395. )
  2396.  
  2397. IF %1 EQU 10 (
  2398.     ECHO Dr. Emmett Brown: No wonder your president has to be an actor. He's gotta look good on television.
  2399.     GOTO :EOF
  2400. )
  2401.  
  2402. IF %1 EQU 11 (
  2403.     ECHO Marty McFly: This is heavy.
  2404.     ECHO Dr. Emmett Brown: Weight has nothing to do with it.
  2405.     GOTO :EOF
  2406. )
  2407.  
  2408. IF %1 EQU 12 (
  2409.     ECHO Marty McFly: If you put your mind to it, you can accomplish anything.
  2410.     GOTO :EOF
  2411. )
  2412.  
  2413. IF %1 EQU 13 (
  2414.     ECHO George McFly: You really think I ought to swear?
  2415.     ECHO Marty McFly: Yes, definitely. Goddamn it, George, swear.
  2416.     GOTO :EOF
  2417. )
  2418.  
  2419. IF %1 EQU 14 (
  2420.     ECHO Dr. Emmett Brown: Things have certainly changed around *here*. I remember when this was all farmland as far the eye could see. Old man Peabody owned all of this. He had this crazy idea about breeding pine trees.
  2421.     GOTO :EOF
  2422. )
  2423.  
  2424. IF %1 EQU 15 (
  2425.     ECHO Marty McFly: Okay. Time circuit's on. Flux capacitor, fluxing. Engine running. All right.
  2426.     ECHO  [the engine stops suddenly]
  2427.     GOTO :EOF
  2428. )
  2429.  
  2430. IF %1 EQU 16 (
  2431.     ECHO Marty McFly: Whoa. This is heavy.
  2432.     ECHO Dr. Emmett Brown: There's that word again. "Heavy." Why are things so heavy in the future? Is there a problem with the Earth's gravitational pull?
  2433.     GOTO :EOF
  2434. )
  2435.  
  2436. IF %1 EQU 17 (
  2437.     ECHO Dr. Emmett Brown: What on Earth is this thing I'm wearing?
  2438.     ECHO Marty McFly: Ah, this, this is a radiation suit.
  2439.     ECHO Dr. Emmett Brown: Radiation suit? Of course. 'Cause of all the fallout from the atomic wars.
  2440.     GOTO :EOF
  2441. )
  2442.  
  2443. IF %1 EQU 18 (
  2444.     ECHO Dr. Emmett Brown: [Marty is showing Doc Brown the flux capacitor in the DeLorean time vehicle] It works! It works!
  2445.     ECHO  [grabs Marty]
  2446.     ECHO Dr. Emmett Brown: I finally invent something that works!
  2447.     ECHO Marty McFly: You bet your ass it works.
  2448.     GOTO :EOF
  2449. )
  2450.  
  2451. IF %1 EQU 19 (
  2452.     ECHO Dr. Emmett Brown: You'll have to forgive the crudeness of this model. I didn't have time to paint it or build it to scale.
  2453.     GOTO :EOF
  2454. )
  2455.  
  2456. IF %1 EQU 20 (
  2457.    REM This is not a quote, but something I added ;)
  2458.     ECHO 2015 is the year of hoverboards!
  2459.     GOTO :EOF
  2460. )
  2461.  
  2462. IF %1 EQU 21 (
  2463.     ECHO Young Biff: Why don't you make like a tree and get out of here?
  2464.     ECHO Old Biff: It's *leave*, you idiot! "Make like a tree, and leave." You sound like a damn fool when you say it wrong.
  2465.     ECHO Young Biff: All right then, LEAVE! And take your book with you!
  2466.     GOTO :EOF
  2467. )
  2468.  
  2469. IF %1 EQU 22 (
  2470.     ECHO Doc: The time-traveling is just too dangerous. Better that I devote myself to study the other great mystery of the universe: women!
  2471.     GOTO :EOF
  2472. )
  2473.  
  2474. IF %1 EQU 23 (
  2475.     ECHO Marty McFly: I don't get it, Doc. I mean, how can all this be happening? It's like we're in Hell or something.
  2476.     ECHO Doc: No, it's Hill Valley. Although I can't imagine Hell being much worse!
  2477.     GOTO :EOF
  2478. )
  2479.  
  2480. IF %1 EQU 24 (
  2481.     ECHO Television announcer: Broadcasting beautiful views 24 hours a day: you're tuned to the Scenery Channel.
  2482.     GOTO :EOF
  2483. )
  2484.  
  2485. IF %1 EQU 25 (
  2486.     ECHO Doc: Marty! What in the name of Sir Isaac H. Newton happened here?
  2487.     GOTO :EOF
  2488. )
  2489.  
  2490. IF %1 EQU 26 (
  2491.     ECHO Goldie Wilson III: [in TV Commercial] Hi friends, Goldie Wilson III for Wilson Hover Conversion Systems. You know, when my Grandpa was Mayor of Hill Valley, he had to worry about traffic problems. But now, you don't have to worry about traffic. I'll hover convert your old road car into a skyway flyer! For only $39,999.95. So come on down and see me Goldie Wilson III, at any one of our 29 convenient locations. Remember, keep 'em flying!
  2492.     GOTO :EOF
  2493. )
  2494.  
  2495. IF %1 EQU 27 (
  2496.     ECHO Young Doc: Nice talking to you. Maybe we'll bump into each other sometime again in the future.
  2497.     ECHO Older Doc: Or in the past.
  2498.     GOTO :EOF
  2499. )
  2500.  
  2501. IF %1 EQU 28 (
  2502.     ECHO Marty McFly: [showing the two boys how to play the shoot 'em up video game] I'll show you, kid. I'm a crack shot at this.
  2503.     ECHO  [shoots a perfect score with the electronic gun]
  2504.     ECHO Video Game Boy #1: You mean you have to use your hands?  That's like a baby's toy!
  2505.     GOTO :EOF
  2506. )
  2507.  
  2508. IF %1 EQU 29 (
  2509.     ECHO Old Biff: Buttheads...
  2510.     GOTO :EOF
  2511. )
  2512.  
  2513. IF %1 EQU 30 (
  2514.     ECHO Doc: I went to a rejuvenation clinic and got a whole natural overhaul. They took out some wrinkles, did hair repair, changed the blood, added a good 30 to 40 years to my life. They also replaced my spleen and colon. What do you think?
  2515.     GOTO :EOF
  2516. )
  2517.  
  2518. IF %1 EQU 31 (
  2519.     ECHO Data: Hey McFly, you bojo, those boards don't work on water!
  2520.     ECHO Whitey: Unless you've got POWER!
  2521.     GOTO :EOF
  2522. )
  2523.  
  2524. IF %1 EQU 32 (
  2525.     ECHO Marty McFly: [arriving in 1955] Oh, this is heavy, Doc. I mean, it's like I was just here yesterday.
  2526.     ECHO Doc: You were here yesterday, Marty.
  2527.     GOTO :EOF
  2528. )
  2529.  
  2530. IF %1 EQU 33 (
  2531.     ECHO Young Doc: Well, good luck for both of our sakes. See you in the future.
  2532.     ECHO Marty McFly: You mean the past?
  2533.     ECHO Young Doc: Exactly.
  2534.     GOTO :EOF
  2535. )
  2536.  
  2537. IF %1 EQU 34 (
  2538.     ECHO Doc: You're just not thinking fourth dimensionally!
  2539.     ECHO Marty McFly: Right, right. I have a real problem with that.
  2540.     GOTO :EOF
  2541. )
  2542.  
  2543. IF %1 EQU 35 (
  2544.     ECHO Young Doc: No wonder this circuit failed. It says "Made in Japan".
  2545.     ECHO Marty McFly: What do you mean, Doc? All the best stuff is made in Japan.
  2546.     ECHO Young Doc: Unbelievable.
  2547.     GOTO :EOF
  2548. )
  2549.  
  2550. IF %1 EQU 36 (
  2551.     ECHO Marty McFly: Great Scott!
  2552.     ECHO Doc: I know, this is heavy.
  2553.     GOTO :EOF
  2554. )
  2555.  
  2556. IF %1 EQU 37 (
  2557.     ECHO Buford "Mad Dog" Tannen: What's your name, dude?
  2558.     ECHO Marty McFly: Uh, Mar- Eastwood. Clint Eastwood.
  2559.     ECHO Buford "Mad Dog" Tannen: What kind of stupid name is that?
  2560.     GOTO :EOF
  2561. )
  2562.  
  2563. IF %1 EQU 38 (
  2564.     ECHO Colt Gun Salesman: [the gun salesman is amazed at Marty's gunmanship at a shooting gallery] Uh, just tell me one thing. Where'd you learn to shoot like that?
  2565.     ECHO Marty McFly: 7-Eleven.
  2566.     GOTO :EOF
  2567. )
  2568.  
  2569. IF %1 EQU 39 (
  2570.     ECHO Marty McFly: [holding up a plate that says "Frisbee"] Hey, Frisbee, far-out.
  2571.     ECHO Seamus McFly: What was the meanin' of that?
  2572.     ECHO Maggie McFly: It was right in front of him.
  2573.     GOTO :EOF
  2574. )
  2575.  
  2576. IF %1 EQU 40 (
  2577.     ECHO Marty McFly: You're the doc, Doc.
  2578.     GOTO :EOF
  2579. )
  2580.  
  2581. IF %1 EQU 41 (
  2582.     ECHO Bartender: [On the day Marty is set to face Buford in a shootout] Seamus! I didn't expect to see you here this early!
  2583.     ECHO Seamus McFly: Aye. But somethin' told me I should be here, as if my future had something to do with it.
  2584.     GOTO :EOF
  2585. )
  2586.  
  2587. ECHO !ERR: Quote Address [ %1 ] is not registered!
  2588. GOTO :EOF
  2589.  
  2590.  
  2591.  
  2592.  
  2593. REM =====================================================================
  2594. REM View Directories
  2595. REM ----------------------------
  2596. REM Within this section, this will allow the user to simply open directories right from the GUI shell -- nothing fancy other than EXPLORER calls.
  2597. REM =====================================================================
  2598.  
  2599.  
  2600. REM # =============================================================================================
  2601. REM # Documentation: What directory does the user wish to view?
  2602. REM # =============================================================================================
  2603. :ViewDirectories
  2604. CALL :DashboardOrClassicalDisplay
  2605. CALL :QuoteDatabase
  2606. ECHO Open a Directory Menu
  2607. ECHO %Separator%
  2608. ECHO.
  2609. ECHO [1] Backup Directory
  2610. ECHO [2] Restore Directory
  2611. ECHO [3] Log Directory
  2612. ECHO [X] Exit
  2613. CALL :UserInput
  2614. GOTO :ViewDirectories_UserInput
  2615.  
  2616.  
  2617.  
  2618. REM # =============================================================================================
  2619. REM # Documentation: Inspect the user's input
  2620. REM # =============================================================================================
  2621. :ViewDirectories_UserInput
  2622. IF "%STDIN%" EQU "1" (
  2623.     CALL :ViewDirectories_InputDriver Backup
  2624.     GOTO :ViewDirectories
  2625. )
  2626. IF "%STDIN%" EQU "2" (
  2627.     CALL :ViewDirectories_InputDriver Restore
  2628.     GOTO :ViewDirectories
  2629. )
  2630. IF "%STDIN%" EQU "3" (
  2631.     CALL :ViewDirectories_InputDriver Log
  2632.     GOTO :ViewDirectories
  2633. )
  2634. IF /I "%STDIN%" EQU "X" GOTO :EOF
  2635. CALL :BadInput& GOTO :ViewDirectories
  2636.  
  2637.  
  2638.  
  2639. REM # =============================================================================================
  2640. REM # Documentation: Manage the users request in a simple package and slightly easier to manage.
  2641. REM # =============================================================================================
  2642. :ViewDirectories_InputDriver
  2643. IF %1 EQU Backup CALL :ViewDirectories_BackupDir
  2644. IF %1 EQU Restore CALL :ViewDirectories_RestoreDir
  2645. IF %1 EQU Log CALL :ViewDirectories_LogDir
  2646. CALL :ClearBuffer
  2647. GOTO :EOF
  2648.  
  2649.  
  2650.  
  2651. REM # =============================================================================================
  2652. REM # Documentation: Open the Backup Directory within the graphical user interface.
  2653. REM # =============================================================================================
  2654. :ViewDirectories_BackupDir
  2655. CALL :Call_WindowsExplorer "%LocalDirectory.Backup%"
  2656. GOTO :EOF
  2657.  
  2658.  
  2659.  
  2660. REM # =============================================================================================
  2661. REM # Documentation: Open the Restore Directory within the graphical user interface.
  2662. REM # =============================================================================================
  2663. :ViewDirectories_RestoreDir
  2664. CALL :Call_WindowsExplorer "%LocalDirectory.Restore%"
  2665. GOTO :EOF
  2666.  
  2667.  
  2668.  
  2669. REM # =============================================================================================
  2670. REM # Documentation: Open the Log Directory within the graphical user interface.
  2671. REM # =============================================================================================
  2672. :ViewDirectories_LogDir
  2673. CALL :Call_WindowsExplorer "%LocalDirectory.Logs%"
  2674. GOTO :EOF
  2675.  
  2676.  
  2677.  
  2678.  
  2679. REM =====================================================================
  2680. REM Error Manager
  2681. REM ----------------------------
  2682. REM When error occurs, the methods below will output and deal with the next step without causing much hassle.
  2683. REM =====================================================================
  2684.  
  2685.  
  2686. REM # =============================================================================================
  2687. REM # Parameters: [{string} File or Path]
  2688. REM # Documentation: When a resource was found missing, this function will be called.  This function will call the sub-function which outputs the error and records the error on the log.
  2689. REM # =============================================================================================
  2690. :ResourceErrorSignal
  2691. IF %ToggleLog% EQU True CALL :ResourceErrorSignal_LogError "%~1"
  2692. CALL :ResourceErrorSignal_DisplayError "%~1"
  2693. GOTO :EOF
  2694.  
  2695.  
  2696.  
  2697. REM # =============================================================================================
  2698. REM # Parameters: [{string} File or Path]
  2699. REM # Documentation: Display the error message on the user's screen from the terminal buffer.
  2700. REM # =============================================================================================
  2701. :ResourceErrorSignal_DisplayError
  2702. IF %UseBell% GEQ 1 (ECHO %SND_BELL% %SND_BELL% %SND_BELL% %SND_BELL%)
  2703. ECHO %SeparatorLong%
  2704. ECHO.&ECHO.
  2705. ECHO ^<!^>       Critical Error Has Occurred!       ^<!^>
  2706. ECHO %SeparatorLong%
  2707. ECHO.
  2708. ECHO Could not find a required file or directory, details below:
  2709. ECHO %Separator%
  2710. ECHO File or Directory that was not found:
  2711. ECHO   %~1
  2712. ECHO.
  2713. PAUSE
  2714. GOTO :EOF
  2715.  
  2716.  
  2717.  
  2718. REM # =============================================================================================
  2719. REM # Parameters: [{string} File or Path]
  2720. REM # Documentation: Log the error message to the ASCII file located within the filesystem.
  2721. REM # =============================================================================================
  2722. :ResourceErrorSignal_LogError
  2723. (ECHO %SeparatorLong%)>> "%STDOUT%"
  2724. (ECHO.&ECHO.)>> "%STDOUT%"
  2725. (ECHO ^<!^>       Critical Error Has Occurred!       ^<!^>)>> "%STDOUT%"
  2726. (ECHO %SeparatorLong%)>> "%STDOUT%"
  2727. (ECHO.)>> "%STDOUT%"
  2728. (ECHO Could not find a required file or directory, details below:)>> "%STDOUT%"
  2729. (ECHO %Separator%)>> "%STDOUT%"
  2730. (ECHO File or Directory that was not found:)>> "%STDOUT%"
  2731. (ECHO   %~1)>> "%STDOUT%"
  2732. (ECHO.)>> "%STDOUT%"
  2733. GOTO :EOF
  2734.  
  2735.  
  2736.  
  2737. REM # =============================================================================================
  2738. REM # Documentation: When the program reaches an error during the backup or restore process, this function will be called.  This function will accordingly output the error message on the log [depending on the ToggleLog var] and display the message on the terminal.
  2739. REM # =============================================================================================
  2740. :CaughtErrorSignal
  2741. IF %ToggleLog% EQU True CALL :CaughtErrorSignal_LogError
  2742. CALL :CaughtErrorSignal_DisplayError
  2743. GOTO :EOF
  2744.  
  2745.  
  2746.  
  2747. REM # =============================================================================================
  2748. REM # Documentation: Display the error message on the user's screen from the terminal buffer.
  2749. REM # =============================================================================================
  2750. :CaughtErrorSignal_DisplayError
  2751. IF %UseBell% GEQ 1 (ECHO %SND_BELL% %SND_BELL% %SND_BELL% %SND_BELL%)
  2752. ECHO %SeparatorLong%
  2753. ECHO.&ECHO.
  2754. ECHO ^<!^>       Critical Error Has Occurred!       ^<!^>
  2755. ECHO %SeparatorLong%
  2756. ECHO.
  2757. ECHO Caught an Error Signal, details below:
  2758. ECHO %Separator%
  2759. ECHO Exit Code: %ExitCode%
  2760. ECHO Program Called: %TaskCaller_NiceProgramName%
  2761. ECHO Command Invoked: %TaskCaller_CallLong%
  2762. ECHO.
  2763. PAUSE
  2764. GOTO :EOF
  2765.  
  2766.  
  2767.  
  2768. REM # =============================================================================================
  2769. REM # Documentation: Log the error message to the ASCII file located within the filesystem.
  2770. REM # =============================================================================================
  2771. :CaughtErrorSignal_LogError
  2772. (ECHO %SeparatorLong%)>> "%STDOUT%"
  2773. (ECHO.&ECHO.)>> "%STDOUT%"
  2774. (ECHO ^<!^>       Critical Error Has Occurred!       ^<!^>)>> "%STDOUT%"
  2775. (ECHO %SeparatorLong%)>> "%STDOUT%"
  2776. (ECHO.)>> "%STDOUT%"
  2777. (ECHO Caught an Error Signal, details below:)>> "%STDOUT%"
  2778. (ECHO %Separator%)>> "%STDOUT%"
  2779. (ECHO Exit Code: %ExitCode%)>> "%STDOUT%"
  2780. (ECHO Program Called: %TaskCaller_NiceProgramName%)>> "%STDOUT%"
  2781. (ECHO Command Invoked: %TaskCaller_CallLong%)>> "%STDOUT%"
  2782. (ECHO.)>> "%STDOUT%"
  2783. GOTO :EOF
  2784.  
  2785.  
  2786.  
  2787. REM # =============================================================================================
  2788. REM # Documentation: When the internal program (preparation phase errors, for example) reaches an error during the backup or restore process, this function will be called.  This function will accordingly output the error message on the log [depending on the ToggleLog var] and display the message on the terminal.
  2789. REM # =============================================================================================
  2790. :CaughtIssueSignal
  2791. IF %ToggleLog% EQU True CALL :CaughtIssueSignal_LogError
  2792. CALL :CaughtIssueSignal_DisplayError
  2793. GOTO :EOF
  2794.  
  2795.  
  2796.  
  2797. REM # =============================================================================================
  2798. REM # Documentation: Display the error message on the user's screen from the terminal buffer.
  2799. REM # =============================================================================================
  2800. :CaughtIssueSignal_DisplayError
  2801. IF %UseBell% GEQ 1 (ECHO %SND_BELL% %SND_BELL% %SND_BELL% %SND_BELL%)
  2802. ECHO %SeparatorLong%
  2803. ECHO.&ECHO.
  2804. ECHO ^<!^>       Critical Issue Was Discovered!       ^<!^>
  2805. ECHO %SeparatorLong%
  2806. ECHO.
  2807. ECHO Caught an Issue Signal!  The operation has been terminated!
  2808. IF %ToggleLog% EQU True (
  2809.     ECHO Check the log for more details:
  2810.     ECHO  Logfile: %STDOUT%
  2811. )
  2812. ECHO.
  2813. PAUSE
  2814. GOTO :EOF
  2815.  
  2816.  
  2817.  
  2818. REM # =============================================================================================
  2819. REM # Documentation: Log the error message to the ASCII file located within the filesystem.
  2820. REM # =============================================================================================
  2821. :CaughtIssueSignal_LogError
  2822. (ECHO %SeparatorLong%)>> "%STDOUT%"
  2823. (ECHO.&ECHO.)>> "%STDOUT%"
  2824. (ECHO ^<!^>       Critical Issue Was Discovered!       ^<!^>)>> "%STDOUT%"
  2825. (ECHO %SeparatorLong%)>> "%STDOUT%"
  2826. (ECHO.)>> "%STDOUT%"
  2827. (ECHO Caught an Issue Signal!  The operation has been terminated!)>> "%STDOUT%"
  2828. (ECHO.)>> "%STDOUT%"
  2829. GOTO :EOF
  2830.  
  2831.  
  2832.  
  2833.  
  2834. REM =====================================================================
  2835. REM Clean-up Local Directories
  2836. REM ----------------------------
  2837. REM This functionality allows the user to thrash all of the data that is stored in the local directories.
  2838. REM This helps the user to remove all of the abundant superfluous data that has accumulated within the user's secondary storage.
  2839. REM =====================================================================
  2840.  
  2841.  
  2842. REM # =============================================================================================
  2843. REM # Documentation: Cleanup menu
  2844. REM # =============================================================================================
  2845. :Cleanup
  2846. CALL :DashboardOrClassicalDisplay
  2847. CALL :Cleanup_Menu_Warning
  2848. ECHO Clean-up Local Directories Menu
  2849. ECHO %Separator%
  2850. ECHO.
  2851. ECHO Clean-up the following directories:
  2852. ECHO.
  2853. ECHO [1] Temporary files
  2854. ECHO [2] Backup files
  2855. ECHO [3] Restore files
  2856. ECHO [4] Log files
  2857. ECHO [A] Everything
  2858. ECHO [X] Exit
  2859. CALL :UserInput
  2860. CALL :Cleanup_UserInput
  2861.  
  2862.  
  2863.  
  2864. REM # =============================================================================================
  2865. REM # Documentation: Inspect the user's input
  2866. REM # =============================================================================================
  2867. :Cleanup_UserInput
  2868. REM Check the parameters and determine how to execute.
  2869. IF "%STDIN%" EQU "1" GOTO :Cleanup_Choice_TemporaryFiles
  2870. IF "%STDIN%" EQU "2" GOTO :Cleanup_Choice_BackupFiles
  2871. IF "%STDIN%" EQU "3" GOTO :Cleanup_Choice_RestoreFiles
  2872. IF "%STDIN%" EQU "4" GOTO :Cleanup_Choice_LogFiles
  2873. IF /I "%STDIN%" EQU "A" GOTO :Cleanup_Choice_Everything
  2874. IF /I "%STDIN%" EQU "X" GOTO :EOF
  2875. CALL :BadInput& GOTO :Cleanup
  2876.  
  2877.  
  2878.  
  2879. REM # =============================================================================================
  2880. REM # Documentation: Print this warning message to alert the user that these changes has effects and consequences
  2881. REM # =============================================================================================
  2882. :Cleanup_Menu_Warning
  2883. ECHO ^<?^>       WARNING       ^<?^>
  2884. ECHO %SeparatorLong%
  2885. ECHO.
  2886. ECHO Clean-up will effectively thrash the data that is located with the directories or just specific directories as requested by the user.  This feature will help the end-user to automatically flush all of the superfluous data that might have accumulated over time, which will allow the user to gain back some free space (from their secondary storage devices).
  2887. ECHO.
  2888. ECHO ATTENTION: Once these files have been deleted, it is possible to easily recover the data!
  2889. ECHO.&ECHO.
  2890. GOTO :EOF
  2891.  
  2892.  
  2893.  
  2894. REM =====================================================
  2895. REM -----------------------------------------------------
  2896. REM =====================================================
  2897.  
  2898.  
  2899.  
  2900. REM # =============================================================================================
  2901. REM # Documentation: Thrash: Log files
  2902. REM #     Requires User Confirmation? No
  2903. REM # =============================================================================================
  2904. :Cleanup_Choice_LogFiles
  2905. CALL :Cleanup_Thrash_LogFiles
  2906. CALL :ClearBuffer
  2907. GOTO :Cleanup
  2908.  
  2909.  
  2910.  
  2911. REM # =============================================================================================
  2912. REM # Documentation: Thrash: Backup files
  2913. REM #     Requires User Confirmation? Yes
  2914. REM # =============================================================================================
  2915. :Cleanup_Choice_BackupFiles
  2916. CALL :Cleanup_Thrash_BackupFiles
  2917. CALL :ClearBuffer
  2918. GOTO :Cleanup
  2919.  
  2920.  
  2921.  
  2922. REM # =============================================================================================
  2923. REM # Documentation: Thrash: Temporary files
  2924. REM #     Requires User Confirmation? No
  2925. REM # =============================================================================================
  2926. :Cleanup_Choice_TemporaryFiles
  2927. CALL :Cleanup_Thrash_TemporaryFiles
  2928. CALL :ClearBuffer
  2929. GOTO :Cleanup
  2930.  
  2931.  
  2932.  
  2933. REM # =============================================================================================
  2934. REM # Documentation: Thrash: Restore files
  2935. REM #     Requires User Confirmation? Yes
  2936. REM # =============================================================================================
  2937. :Cleanup_Choice_RestoreFiles
  2938. CALL :Cleanup_Thrash_RestoreFiles
  2939. CALL :ClearBuffer
  2940. GOTO :Cleanup
  2941.  
  2942.  
  2943.  
  2944. REM # =============================================================================================
  2945. REM # Documentation: Thrash: Everything [Logs, Backup, Temporary, and Restore]
  2946. REM #     Requires User Confirmation? Yes
  2947. REM # =============================================================================================
  2948. :Cleanup_Choice_Everything
  2949. CALL :Cleanup_Thrash_LogFiles
  2950. CALL :Cleanup_Thrash_BackupFiles
  2951. CALL :Cleanup_Thrash_TemporaryFiles
  2952. CALL :Cleanup_Thrash_RestoreFiles
  2953. CALL :ClearBuffer
  2954. GOTO :Cleanup
  2955.  
  2956.  
  2957.  
  2958. REM =====================================================
  2959. REM -----------------------------------------------------
  2960. REM =====================================================
  2961.  
  2962.  
  2963.  
  2964. REM # =============================================================================================
  2965. REM # Documentation: Thrash all of the log files
  2966. REM # =============================================================================================
  2967. :Cleanup_Thrash_LogFiles
  2968. ECHO Thrashing log files. . .
  2969. CALL :Cleanup_Thrash_DelCall "%LocalDirectory.Logs%"
  2970. GOTO :EOF
  2971.  
  2972.  
  2973.  
  2974. REM # =============================================================================================
  2975. REM # Documentation: Thrash all of the backup files.  This will require a confirmation pass from the user.
  2976. REM # =============================================================================================
  2977. :Cleanup_Thrash_BackupFiles
  2978. ECHO Thrashing backup contents and database. . .
  2979. CALL :Cleanup_Thrash_Confirm Backup
  2980. IF %ERRORLEVEL% EQU 0 (
  2981.    REM The user really wanted to remove the contents within this directory
  2982.     CALL :Cleanup_Thrash_DelCall "%LocalDirectory.Backup%"
  2983. ) ELSE (
  2984.    REM Do not remove the contents within the directory.
  2985. )
  2986. GOTO :EOF
  2987.  
  2988.  
  2989.  
  2990. REM # =============================================================================================
  2991. REM # Documentation: Thrash all of the restore files.  This will require a confirmation pass from the user.
  2992. REM # =============================================================================================
  2993. :Cleanup_Thrash_RestoreFiles
  2994. ECHO Thrashing restore contents. . .
  2995. CALL :Cleanup_Thrash_Confirm Restore
  2996. IF %ERRORLEVEL% EQU 0 (
  2997.    REM The user really wanted to remove the contents within this directory
  2998.     CALL :Cleanup_Thrash_DelCall "%LocalDirectory.Restore%"
  2999. ) ELSE (
  3000.    REM Do not remove the contents within the directory.
  3001. )
  3002. GOTO :EOF
  3003.  
  3004.  
  3005.  
  3006. REM # =============================================================================================
  3007. REM # Documentation: Thrash all of the Temporary files
  3008. REM # =============================================================================================
  3009. :Cleanup_Thrash_TemporaryFiles
  3010. ECHO Thrashing temporary files. . .
  3011. CALL :Cleanup_Thrash_DelCall "%LocalDirectory.Temp%"
  3012. GOTO :EOF
  3013.  
  3014.  
  3015.  
  3016. REM # =============================================================================================
  3017. REM # Documentation: This will display an error if incase the local directory files could not successfully expunged.
  3018. REM # =============================================================================================
  3019. :Cleanup_Thrash_Error
  3020. ECHO ^<!^>       ERROR       ^<!^>
  3021. ECHO %SeparatorLong%
  3022. ECHO.
  3023. ECHO Could not successfully thrash all of the files!
  3024. ECHO.
  3025. PAUSE
  3026. ECHO.&ECHO.
  3027. GOTO :EOF
  3028.  
  3029.  
  3030.  
  3031. REM # =============================================================================================
  3032. REM # Parameters: [{String} NiceNameDirectory]
  3033. REM # Documentation: Display a confirmation request.  Just incase the user accidentally presses the wrong key.
  3034. REM # =============================================================================================
  3035. :Cleanup_Thrash_Confirm
  3036. ECHO.
  3037. ECHO ^<?^>       ATTENTION       ^<?^>
  3038. ECHO %SeparatorLong%
  3039. ECHO.
  3040. ECHO Are you sure you want to remove all contents from the [ %1 ] directory?
  3041. ECHO.
  3042. ECHO [Yes] Yes
  3043. ECHO Any other key will mean 'no'.
  3044. CALL :UserInput
  3045. CALL :Cleanup_Thrash_Confirm_UserInput
  3046. EXIT /B %ERRORLEVEL%
  3047.  
  3048.  
  3049.  
  3050. REM # =============================================================================================
  3051. REM # Documentation: Make sure that user really wanted to remove a specific directory.
  3052. REM # =============================================================================================
  3053. :Cleanup_Thrash_Confirm_UserInput
  3054. IF /I "%STDIN%" EQU "Yes" (
  3055.     EXIT /B 0
  3056. ) ELSE (
  3057.     EXIT /B 1
  3058. )
  3059.  
  3060.  
  3061.  
  3062. REM # =============================================================================================
  3063. REM # Documentation: This function will allow the user to thrash a collection of files as requested.
  3064. REM # Parameters: [{string}Directory]
  3065. REM # =============================================================================================
  3066. :Cleanup_Thrash_DelCall
  3067. REM Expunge all data from the directories and subdirectories
  3068. DEL /F /Q /S "%~1\*.*" > NUL || CALL :Cleanup_Thrash_Error
  3069. REM Expunge all of the directories
  3070. FOR /D %%i IN ("%~1\*") DO RMDIR /Q /S "%%i" > NUL || CALL :Cleanup_Thrash_Error
  3071. GOTO :EOF
  3072.  
  3073.  
  3074.  
  3075.  
  3076. REM =====================================================================
  3077. REM Terminating Protocol
  3078. REM ----------------------------
  3079. REM These functions will determine how the program is going to be terminated.
  3080. REM =====================================================================
  3081.  
  3082.  
  3083. REM # =============================================================================================
  3084. REM # Documentation: When the user is ready to close the program, this function will make sure that the program reports the proper Exit Code along with any necessary statements - if needed.
  3085. REM # =============================================================================================
  3086. :Terminate_MainExit
  3087. IF %FatalExit% EQU 0 (
  3088.     SET scriptExitCode=0
  3089.     GOTO :Terminate
  3090. ) ELSE (
  3091.     SET scriptExitCode=1
  3092.     GOTO :Terminate
  3093. )
  3094.  
  3095.  
  3096.  
  3097. REM =====================================================================
  3098. REM Termination
  3099. REM ----------------------------
  3100. REM Terminate this script
  3101. REM =====================================================================
  3102. :Terminate
  3103. ECHO.&ECHO.
  3104. ECHO Closing module...
  3105. GOTO :EOF
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top