-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindowsBackUpScriptDmW.bat
169 lines (146 loc) · 4.81 KB
/
WindowsBackUpScriptDmW.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
rem Copyright 2019 DeadManWalking (DeadManWalkingTO-GitHub), <https://github.com/DeadManWalkingTO>, <deadmanwalkingto@gmail.com>
:customcode
cls
rem ==================== Your Code Starts Here ====================
rem ==================== Your Code Starts Here ====================
rem ==================== Your Code Starts Here ====================
rem Set InputPath
set InputPath=C:\Docs
rem Set Output Filename
set OutputFilename=BackUp
rem ==================== Your Code Ends Here ====================
rem ==================== Your Code Ends Here ====================
rem ==================== Your Code Ends Here ====================
cls
rem ========== Pre ==========
:pre
cls
rem Don't echo to standard output
cls
@echo off
rem Set Version info
set V=1.4.8
rem Change colors
color 1F
rem Set Author
set Author=DeadManWalking (DeadManWalkingTO-GitHub)
Rem Set Program Name
set ProgramName=WindowsBackUpScriptDmW
rem Set Title
title %ProgramName% By %Author%
rem Set Size
mode con: cols=120 rem lines=60
Rem ========== Start ==========
:start
cls
echo ###############################################################################
echo.
echo %ProgramName% Version %V%
echo.
echo AUTHOR: %Author%
echo.
echo ###############################################################################
echo.
echo %ProgramName%
echo 1. BackUp.
echo 2. Compress (Rar Best).
echo 3. Save.
echo.
echo Additional:
echo - Auto Invoking UAC for Privilege Escalation
echo.
timeout /T 1 /NOBREAK > nul
rem ========== Automatically Check & Get Admin Rights ==========
:init
setlocal DisableDelayedExpansion
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>nul 2>nul
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
echo.
echo ###############################################################################
echo Invoking UAC for Privilege Escalation
echo ###############################################################################
echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
echo args = "ELEV " >> "%vbsGetPrivileges%"
echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
echo Next >> "%vbsGetPrivileges%"
echo UAC.ShellExecute "!batchPath!", args, "", "runas", 3 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
rem ========== Initializing ==========
:initializing
rem Set RarPath
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT
rem if %OS%==32BIT echo This is a 32bit operating system
rem if %OS%==64BIT echo This is a 64bit operating system
set RarPath=.\System\Rar32.exe
if %OS%==64BIT set RarPath=.\System\Rar.exe
rem Set OutputPath
set OutputPath=.\BackUp\%OutputFilename%
rem Set BackUp Date
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set BackUpDate=%%c-%%a-%%b)
rem Set BackUp Rar Options
set RarOptions=a -m5
rem Set FullCommand
set FullCommand=%RarPath% %RarOptions% %OutputPath%---%BackUpDate% %InputPath%
rem echo %FullCommand%
rem ========== Run ==========
:run
rem Change Directory
echo ==================================================
echo Change Directory
echo.
cd \
if %ERRORLEVEL%==0 (echo. & echo Done) else (echo. & echo Fail & pause & goto :eof)
echo ==================================================
echo.
timeout 1 > nul
rem Make Directory
echo ==================================================
echo Make Directory
echo.
if not exist BackUp mkdir BackUp
if %ERRORLEVEL%==0 (echo. & echo Done) else (echo. & echo Fail & pause & goto :eof)
echo ==================================================
echo.
timeout 1 > nul
rem Run BackUp
echo ==================================================
echo Run BackUp
echo.
%FullCommand%
if %ERRORLEVEL%==0 (echo. & echo Done) else (echo. & echo Fail & pause & goto :eof)
echo ==================================================
echo.
timeout 1 > nul
rem ========== Finish ==========
:finish
echo.
echo ###############################################################################
echo.
echo %ProgramName% Version %V%
echo.
echo AUTHOR: %Author%
echo.
echo ###############################################################################
echo.
echo BackUp stored to %OutputFilename%---%BackUpDate%.
echo.
echo ###############################################################################
echo.
echo Press any key to exit.
echo ###############################################################################
pause > nul
rem ========== End ==========
rem ========== EoF ==========