Skip to content

Instantly share code, notes, and snippets.

@maciakl
Created July 1, 2022 04:34
Show Gist options
  • Save maciakl/16b248c1b7ccf21f9dc04a1d9744e74b to your computer and use it in GitHub Desktop.
Save maciakl/16b248c1b7ccf21f9dc04a1d9744e74b to your computer and use it in GitHub Desktop.

Revisions

  1. maciakl created this gist Jul 1, 2022.
    52 changes: 52 additions & 0 deletions shadowcopy.cmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    @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