Created
July 1, 2022 04:34
-
-
Save maciakl/16b248c1b7ccf21f9dc04a1d9744e74b to your computer and use it in GitHub Desktop.
Interactive helper script to create a shadowcopy job that will create a snapshot of your c: drive every day at 1pm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if "%1" == "elevated" goto start | |
powershell -command "Start-Process %~nx0 elevated -Verb runas" | |
goto :eof | |
:start | |
@echo off | |
cls | |
echo. | |
echo. | |
echo Shadowcopy Helper | |
echo ================= | |
echo. | |
CALL :COMPUTERNAME | |
CALL :CHECK | |
echo. | |
choice /M "Create or Quit" /C CQ | |
if %ERRORLEVEL% == 1 ( CALL :CREATE ) | |
if %ERRORLEVEL% == 2 ( goto :eof ) | |
goto :start | |
:CREATE | |
call :GETPW | |
schtasks /create /sc daily /tn "DG\shadowcopy" /st 13:00 /ru %COMPUTERNAME%\Administrator /rp %pw% /tr "wmic shadowcopy call create Volume=""c:\\""" | |
echo. | |
pause | |
goto :eof | |
:CHECK | |
echo. | |
schtasks | findstr shadowcopy | |
echo. | |
goto :eof | |
:COMPUTERNAME | |
for /f "skip=1" %%i in ('wmic computersystem get name') DO ( | |
SET COMPUTERNAME=%%i | |
goto :eof | |
) | |
:GETPW | |
set /P pw=Enter password, then press ENTER: | |
goto :eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment