@echo off
if /i "%UserName%" == "SYSTEM" (Goto GotAdmin) else (reg query "HKLM\SYSTEM\ControlSet001\Control\MiniNT" 1>nul 2>nul&&Goto GotAdmin)
:BatchGotAdmin
Set _Args=&Set Args=%*
if `%1` neq `` Set "_Args=%Args:"=""%"
if exist %WinDir%\System32\fltMC.exe fltMC 1>nul 2>nul||(echo CreateObject^("Shell.Application"^).ShellExecute "cmd.exe","/c """"%~f0"" %_Args%""",,"runas",1 >"%TEMP%\getAdmin.vbs"&(CScript 1>nul 2>nul&&CScript //nologo "%TEMP%\getAdmin.vbs" 1>nul 2>nul||"%TEMP%\getAdmin.vbs" 2>nul)&del /f /q "%TEMP%\getAdmin.vbs" 2>nul&Exit /b)

:GotAdmin
Pushd "%CD%"&cd /d "%~dp0"
find /? 1>nul 2>nul&&Set "findstr=find /i "||Set findstr=
findstr /? 1>nul 2>nul&&Set "findstr=findstr /i /c:"
if not defined findstr Call :EchoX "cf.: 找不到 find.exe 文件。"&Call :Delay 5 +&Exit /b
reg /? 1>nul 2>nul||(Call :EchoX "cf.: 找不到 reg.exe 文件。"&Call :Delay 5 +&Exit /b)
sc query 1>nul 2>nul||(Call :EchoX "cf.: 找不到 sc.exe 文件。"&Call :Delay 5 +&Exit /b)
REM 判断输入参数
Set hint=&if /i "%~1" == "uninsta" Goto UnInsta
Title &ver|%findstr%" 5." 1>nul 2>nul&&Title 清理卸载&(if exist %WinDir%\System32\ureg.dll Mode 36,6 2>nul)&Color 2f
Set hint=启用提示

:UnInsta
reg delete "HKCU\SOFTWARE\Snapshot" /f 1>nul 2>nul
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.SNA" /f 1>nul 2>nul
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.SNA" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\ExcludedApplications" /f /v "Snapshot.exe" 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\ExcludedApplications" /f /v "Snapshot64.exe" 1>nul 2>nul
reg delete "HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" /f /v "%~dp0Snapshot64.exe.ApplicationCompany" 1>nul 2>nul
reg delete "HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" /f /v "%~dp0Snapshot64.exe.FriendlyAppName" 1>nul 2>nul
reg delete "HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" /f /v "%~dp0Snapshot备份还原.exe.FriendlyAppName" 1>nul 2>nul
reg delete "HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" /f /v "%~dp0Snapshot 备份还原.exe.FriendlyAppName" 1>nul 2>nul
Call :DelReg "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\ExcludedApplications" "sukey"
Set BEPath=,&for /f "tokens=2*" %%i in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v "BootExecute" 2^>nul') do Set "BEPath=%%~j"
Setlocal EnableDelayedExpansion
Set "BEPath=!BEPath:snapnative.exe\0=!"
if "!BEPath:~-1!" == "\" Set "BEPath=!BEPath!\"
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /f /v "BootExecute" /t REG_MULTI_SZ /d "!BEPath!" 1>nul 2>nul
Endlocal
REM 删除配置文件
rd /s /q "%AppData%\..\Local\Snapshot" 1>nul 2>nul
del /f /q "Snapshot_Error.log" 1>nul 2>nul
REM 删除 SNAPSHOD0 驱动
net stop "SNAPSHOD0" 1>nul 2>nul&sc stop "SNAPSHOD0" 1>nul 2>nul&sc delete "SNAPSHOD0" 1>nul 2>nul
reg delete "HKLM\SYSTEM\CurrentControlSet\Services\SNAPSHOD0" /f 1>nul 2>nul
reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Snapshot" /f 1>nul 2>nul
del /f /q "%WinDir%\System32\Drivers\SNAPSHOD0.sys" 1>nul 2>nul
del /f /q "%WinDir%\System32\SnapNative.exe" 1>nul 2>nul
Goto End

:End
if defined hint (Set hint=&cls&Call :EchoX "2e.:清理完成！！"&Call :Delay 2 +)
cd.&Exit /b

:DelReg :: 删除注册表项 (父项路径\子项)，删除后父项无任何子项则也删除 <%1=PReg|父项路径> <%2=SReg|子项>。
Set "PReg=%~1"&Set "SReg=%~2"
reg delete "%PReg%\%SReg%" /f 1>nul 2>nul
ver|%findstr%" 5." 1>nul 2>nul&&Set n=-2||Set n=0
for /f "delims=" %%i in ('reg query "%PReg%" /s 2^>nul') do Set /a n+=1
if %n% lss 1 reg delete "%PReg%" /f 1>nul 2>nul
Goto :eof

:Delay :: 延迟操作 <%1=Sec|延迟秒数> [%2=+|显示倒计时]。
if "%~2" == "+" (Set #=2) else Set #=1
if exist %WinDir%\System32\timeout.exe (timeout /t %~1 %#%>nul) else if exist %WinDir%\System32\choice.exe (choice /t %~1 /d y /n >nul) else ping 127.1 -n %~1 >nul
Goto :eof

:EchoX :: 显示彩色文字 (不支持半角字符 \ / : * ? " < >|. % ! ~)。
Setlocal EnableDelayedExpansion
Set echox=EchoX.exe&&!echox! 1>nul 2>nul||(Set echox=&mkdir "%TEMP%\EchoX" 2>nul&&attrib +s +h "%TEMP%\EchoX" 2>nul)
for %%a in (%*) do (
    Set "param=%%~a"&Set "color=!param:~0,2!"&(if not exist %WinDir%\System32\findstr.exe if not defined echox Set "color=xx")
    Set n=0&(if "!param:~2,2!" == "::" Set n=1)&(if "!param:~2,2!" == ".:" Set n=2)
    if !n! gtr 0 (
        if /i "!color!" == "xx" (Set /p="_!param:~4!"<nul) else (Set param=%%~nxa&if defined echox (!echox! -c !color! -n "!param:~4!") else (Pushd "%TEMP%\EchoX" 2>nul&>"!param:~4!",Set /p= <nul&findstr /a:!color! .* "!param:~4!*"&del "!param:~4!"&Popd))
        if !n! == 2 echo.
    ) else if defined param Set /p="_!param!"<nul
)
Endlocal&Goto :eof