[Batch] UnChew7 v0.1 for uninstalling Chew7 v1.0 / v1.1

Discussion in 'Scripting' started by anemeros, Mar 18, 2011.

  1. anemeros

    anemeros MDL Developer

    Aug 12, 2009
    81
    280
    0
    #1 anemeros, Mar 18, 2011
    Last edited by a moderator: Apr 20, 2017
    Code:
    @echo off
    setlocal enableextensions
    
    :header
    set this="%~0"
    if "%1" equ "1" (goto :at1)
    if "%1" equ "2" (goto :at2)
    
    :vars
    set ERRORLEVEL=
    set flaw=0
    set sr=%SystemRoot%
    set ss=%sr%\System32
    set sw=%sr%\SysWOW64
    set ncmd="%sr%\SysNative\cmd.exe"
    if not exist %ncmd% (set ncmd="%ss%\cmd.exe")
    set tcmd="%TEMP%\cmd1337.exe"
    if exist "%sw%\cmd.exe" (set arch=64) else (set arch=32)
    set x64=%ss%
    set x86=%sw%
    if %arch% equ 32 (set x86=%x64%)
    set bakf=%ALLUSERSPROFILE%\Microsoft\Windows\SXS
    set c1=reg delete HKLM\SOFTWARE\Chew7 /f^>nul
    set c2=del /f /q "%ss%\cwlog.dtl"
    set c3=rd /s /q %bakf%
    if exist "%sr%\ServerManager" (for /f "usebackq tokens=*" %%n in (`dir /s /b "%sr%\assembly\GAC_64\Microsoft.Windows.ServerManager\Microsoft.Windows.ServerManager.dll"`) do set mwsm=%%n) else (set mwsm=)
    
    :main
    cls
    echo.-- The Ghetto Chew7 Uninstaller v0.1 by anemeros --
    echo.
    echo.(1)  Uninstall Chew7 v1.0
    echo.(2)  Uninstall Chew7 v1.1
    echo.(3)  Quit
    echo.
    choice /c 123 /n /m ">"
    if %ERRORLEVEL% equ 1 (set tver=1.0)
    if %ERRORLEVEL% equ 2 (set tver=1.1&goto :common1)
    if %ERRORLEVEL% equ 3 (goto :eof)
    :resume
    call :%tver%
    if %flaw% equ 0 (goto :success) else (goto :failure)
    goto :eof
    
    :1.0
    set st=schtasks /delete /tn \Microsoft\Windows\PMS
    %st%\PMS /f>nul
    %st%\ResetDTL /f>nul
    %st% /f>nul
    call :common2
    goto :eof
    
    :1.1
    call :zed 32 "%x86%\winver.exe"
    if %arch% equ 64 (call :zed 64 "%x64%\winver.exe")
    reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Chew7Hale /f>nul
    call :common2
    goto :eof
    
    :zed
    set bf="%bakf%\%1\%~nx2"
    if not exist %2 (goto :eof)
    if not exist %bf% (goto :eof)
    takeown /f %2>nul
    icacls %2 /grant *s-1-1-0:f>nul
    :tmp
    set tf="%TEMP%\%RANDOM%%RANDOM%.tmp"
    if exist %tf% (goto :tmp) else (type nul>%tf%)
    move /y %2 %tf%>nul&&move /y %bf% %2>nul
    set /a flaw=flaw+%ERRORLEVEL%
    GOTO :EOF
    
    :endtask
    tasklist /fi "imagename eq %~1"|find /i "%~1">nul
    if %ERRORLEVEL% equ 0 (taskkill /f /im "%~1">nul)
    goto :eof
    
    :common1
    copy /y %ncmd% %tcmd%>nul
    %tcmd% /c %this% 1
    :at1
    reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Chew7Hale /d "cmd.exe /c del /f /q /a:ash \"%ss%\hale.exe\"" /f>nul
    call :endtask "cmd.exe"
    %ncmd% /c %this% 2
    :at2
    for %%a in (%tcmd%) do call :endtask "%%~nxa"
    del /f /q %tcmd%
    goto :resume
    
    :common2
    call :zed 32 "%x86%\slmgr.vbs"
    call :zed 32 "%x86%\slwga.dll"
    call :zed 32 "%x86%\sppwmi.dll"
    if %arch% equ 32 (
    call :zed 32 "%x86%\user32.dll"
    call :zed 32 "%x86%\systemcpl.dll"
    call :zed 32 "%x86%\slui.exe"
    call :zed 32 "%x86%\sppcommdlg.dll"
    call :zed 32 "%x86%\sppuinotify.dll"
    call :zed 32 "%x86%\winlogon.exe"
    call :zed 32 "%x86%\wlms\wlms.exe"
    ) else (
    call :zed 64 "%x64%\slmgr.vbs"
    call :zed 64 "%x64%\slwga.dll"
    call :zed 64 "%x64%\sppwmi.dll"
    call :zed 64 "%x64%\user32.dll"
    call :zed 64 "%x64%\systemcpl.dll"
    call :zed 64 "%x64%\slui.exe"
    call :zed 64 "%x64%\sppcommdlg.dll"
    call :zed 64 "%x64%\sppuinotify.dll"
    call :zed 64 "%x64%\winlogon.exe"
    call :zed 64 "%x64%\wlms\wlms.exe"
    if "%mwsm%" neq "" (call :zed 64 "%mwsm%")
    )
    %c1%
    %c2%
    if %flaw% equ 0 (%c3%)
    goto :eof
    
    :success
    echo.THE OPERATION WAS SUCCESSFUL! ^:^)
    goto :end
    
    :failure
    if %flaw% neq 1 (set s=s were) else (set s= was)
    echo.Unfortunately, something has gone wrong and %flaw% error%s% encountered.
    echo.choice /c yn /n /m "Would you like me to run a system scan now?"
    if %ERRORLEVEL% equ 1 (
    echo.This process will take a while. Please do not interrupt it.&echo.
    sfc /scannow
    )
    goto :end
    
    :end
    echo.&echo.All operations have finished.&echo.
    choice /c yn /n /m "Would you like me to restart your computer now?"
    if %ERRORLEVEL% equ 1 (shutdown /r /f /t 0 /d p:2:18)
    goto :eof
     

    Attached Files:

    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...