Skip to content

Instantly share code, notes, and snippets.

@maciakl
Created July 1, 2022 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciakl/16b248c1b7ccf21f9dc04a1d9744e74b to your computer and use it in GitHub Desktop.
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.
@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