fix batch installer and split back into installer and uninstaller
This commit is contained in:
17
README.md
17
README.md
@@ -44,21 +44,12 @@ If you are interested, you can read my original write up on discovering the CPU
|
|||||||
- Byte pattern-based patching, which means it will usually keep working even after new updates come out.
|
- Byte pattern-based patching, which means it will usually keep working even after new updates come out.
|
||||||
- Absolutely zero dependencies.
|
- Absolutely zero dependencies.
|
||||||
|
|
||||||
## How to use unattended feature in the batch script setup
|
## How to use unattended feature in the batch setup scripts
|
||||||
|
|
||||||
`wufuc_setup.bat` supports three command line parameters, that can be combined to change the behavior of the script:
|
`install_wufuc.bat` and `uninstall_wufuc.bat` both support two command line parameters that can used alone or be combined to change the behavior of the scripts:
|
||||||
|
|
||||||
- `/NORESTART` - automatically declines rebooting after setup finishes.
|
- `/NORESTART` - Automatically declines rebooting after the setup finishes.
|
||||||
- `/UNATTENDED` - skips all prompts for user interaction. **Beware: this will automatically restart your PC, unless combined with `/NORESTART`.**
|
- `/UNATTENDED` - Skips all prompts for user interaction, and automatically restarts unless `/NORESTART` is also specified.
|
||||||
- `/UNINSTALL` - skips the prompt that asks if you want to install or uninstall.
|
|
||||||
|
|
||||||
You can also change the default behavior of the script by modifying these lines near the beginning of the script:
|
|
||||||
|
|
||||||
```bat
|
|
||||||
call :set_uninstall 0
|
|
||||||
call :set_unattended 0
|
|
||||||
call :set_norestart 0
|
|
||||||
```
|
|
||||||
|
|
||||||
## How it works
|
## How it works
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
@echo off
|
@echo off
|
||||||
title wufuc installer
|
|
||||||
:: Copyright (C) 2017 zeffy
|
:: Copyright (C) 2017 zeffy
|
||||||
|
|
||||||
:: This program is free software: you can redistribute it and/or modify
|
:: This program is free software: you can redistribute it and/or modify
|
||||||
@@ -15,9 +14,6 @@ title wufuc installer
|
|||||||
:: You should have received a copy of the GNU General Public License
|
:: You should have received a copy of the GNU General Public License
|
||||||
:: along with this program. If not, see <http://www.gnu.org/licenses/>.
|
:: along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
call :set_uninstall 0
|
|
||||||
call :set_unattended 0
|
|
||||||
call :set_norestart 0
|
|
||||||
|
|
||||||
echo Copyright ^(C^) 2017 zeffy
|
echo Copyright ^(C^) 2017 zeffy
|
||||||
echo This program comes with ABSOLUTELY NO WARRANTY.
|
echo This program comes with ABSOLUTELY NO WARRANTY.
|
||||||
@@ -25,21 +21,34 @@ echo This is free software, and you are welcome to redistribute it
|
|||||||
echo under certain conditions; see COPYING.txt for details.
|
echo under certain conditions; see COPYING.txt for details.
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
|
call :set_uninstall 0
|
||||||
|
call :set_unattended 0
|
||||||
|
call :set_norestart 0
|
||||||
|
|
||||||
|
:loop_args
|
||||||
|
if [%1]==[] goto :check_admin
|
||||||
|
if /I "%1"=="/UNINSTALL" call :set_uninstall 1
|
||||||
|
if /I "%1"=="/UNATTENDED" call :set_unattended 1
|
||||||
|
if /I "%1"=="/NORESTART" call :set_norestart 1
|
||||||
|
shift /1
|
||||||
|
goto :loop_args
|
||||||
|
:set_uninstall
|
||||||
|
set "UNINSTALL=%~1"
|
||||||
|
exit /b
|
||||||
|
:set_unattended
|
||||||
|
set "UNATTENDED=%~1"
|
||||||
|
exit /b
|
||||||
|
:set_norestart
|
||||||
|
set "NORESTART=%~1"
|
||||||
|
exit /b
|
||||||
|
|
||||||
|
:check_admin
|
||||||
fltmc >nul 2>&1 || (
|
fltmc >nul 2>&1 || (
|
||||||
echo This batch script requires administrator privileges. Right-click on
|
echo This batch script requires administrator privileges. Right-click on
|
||||||
echo %~nx0 and select "Run as administrator".
|
echo the script and select "Run as administrator".
|
||||||
goto :die
|
goto :die
|
||||||
)
|
)
|
||||||
|
|
||||||
:loop_args
|
|
||||||
if [%1]==[] goto :check_requirements
|
|
||||||
if /I "%1"=="/UNATTENDED" call :set_unattended 1
|
|
||||||
if /I "%1"=="/UNINSTALL" call :set_uninstall 1
|
|
||||||
if /I "%1"=="/NORESTART" call :set_norestart 1
|
|
||||||
shift
|
|
||||||
goto :loop_args
|
|
||||||
|
|
||||||
:check_requirements
|
|
||||||
echo Checking system requirements...
|
echo Checking system requirements...
|
||||||
|
|
||||||
set "systemfolder=%systemroot%\System32"
|
set "systemfolder=%systemroot%\System32"
|
||||||
@@ -63,16 +72,14 @@ goto :dll_exists
|
|||||||
|
|
||||||
:is_wow64
|
:is_wow64
|
||||||
set "systemfolder=%systemroot%\Sysnative"
|
set "systemfolder=%systemroot%\Sysnative"
|
||||||
|
|
||||||
:is_x64
|
:is_x64
|
||||||
set "WINDOWS_ARCHITECTURE=x64"
|
set "WINDOWS_ARCHITECTURE=x64"
|
||||||
set "wufuc_dll=wufuc64.dll"
|
set "wufuc_dll=wufuc64.dll"
|
||||||
|
|
||||||
:dll_exists
|
:dll_exists
|
||||||
set "wufuc_dll_fullpath=%~dp0%wufuc_dll%"
|
set "wufuc_dll_fullpath=%~dp0%wufuc_dll%"
|
||||||
if exist "%wufuc_dll_fullpath%" (
|
if exist "%wufuc_dll_fullpath%" goto :check_winver
|
||||||
goto :get_ver
|
|
||||||
)
|
|
||||||
echo ERROR - Could not find %wufuc_dll_fullpath%!
|
echo ERROR - Could not find %wufuc_dll_fullpath%!
|
||||||
echo.
|
echo.
|
||||||
echo This most likely means you tried to clone the repository.
|
echo This most likely means you tried to clone the repository.
|
||||||
@@ -87,14 +94,7 @@ echo This error could also mean that your anti-virus deleted or quarantined %wuf
|
|||||||
echo in which case, you will need to make an exception and restore it.
|
echo in which case, you will need to make an exception and restore it.
|
||||||
goto :die
|
goto :die
|
||||||
|
|
||||||
:get_ver
|
:check_winver
|
||||||
call :get_filever "%wufuc_dll_fullpath%"
|
|
||||||
if "%UNINSTALL%"=="1" (
|
|
||||||
title wufuc uninstaller - v%Version%
|
|
||||||
) else (
|
|
||||||
title wufuc installer - v%Version%
|
|
||||||
)
|
|
||||||
|
|
||||||
ver | findstr " 6\.1\." >nul && (
|
ver | findstr " 6\.1\." >nul && (
|
||||||
echo Detected supported operating system: Windows 7 %WINDOWS_ARCHITECTURE%
|
echo Detected supported operating system: Windows 7 %WINDOWS_ARCHITECTURE%
|
||||||
goto :check_mode
|
goto :check_mode
|
||||||
@@ -119,29 +119,8 @@ set "regkey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Executi
|
|||||||
set "wufuc_dll_target=%systemfolder%\%wufuc_dll%"
|
set "wufuc_dll_target=%systemfolder%\%wufuc_dll%"
|
||||||
|
|
||||||
if "%UNINSTALL%"=="1" goto :confirm_uninstall
|
if "%UNINSTALL%"=="1" goto :confirm_uninstall
|
||||||
if "%UNATTENDED%"=="1" goto :install
|
|
||||||
|
|
||||||
:pick_mode
|
:: BEGIN INSTALL MODE /////////////////////////////////////////////////////////
|
||||||
echo.
|
|
||||||
echo Please enter one of the following numbers:
|
|
||||||
echo.
|
|
||||||
echo 1 - Install
|
|
||||||
echo 2 - Uninstall
|
|
||||||
echo.
|
|
||||||
set /p INSTALL_MODE=Would you like to install or uninstall wufuc?
|
|
||||||
|
|
||||||
if "%INSTALL_MODE%"=="1" (
|
|
||||||
goto :confirm_install
|
|
||||||
)
|
|
||||||
if "%INSTALL_MODE%"=="2" (
|
|
||||||
call :set_uninstall 1
|
|
||||||
goto :confirm_uninstall
|
|
||||||
)
|
|
||||||
echo.
|
|
||||||
echo Invalid choice, please enter 1 for install or 2 for uninstall.
|
|
||||||
goto :pick_mode
|
|
||||||
|
|
||||||
:: BEGIN INSTALL MODE
|
|
||||||
:confirm_install
|
:confirm_install
|
||||||
if "%UNATTENDED%"=="1" goto :install
|
if "%UNATTENDED%"=="1" goto :install
|
||||||
echo.
|
echo.
|
||||||
@@ -151,23 +130,23 @@ echo systems with Intel Kaby Lake, AMD Ryzen, or other unsupported processors.
|
|||||||
echo.
|
echo.
|
||||||
echo Please be absolutely sure you really need wufuc before proceeding.
|
echo Please be absolutely sure you really need wufuc before proceeding.
|
||||||
echo.
|
echo.
|
||||||
set /p CONTINUE_INSTALL=Enter 'Y' if you want to install wufuc:
|
for /f "tokens=*" %%i in ('wmic /output:stdout datafile where "name='%wufuc_dll_fullpath:\=\\%'" get Version /value ^| find "="') do set "%%i"
|
||||||
|
set /p CONTINUE_INSTALL=Enter 'Y' if you want to install wufuc %Version%:
|
||||||
if /I "%CONTINUE_INSTALL%"=="Y" goto :install
|
if /I "%CONTINUE_INSTALL%"=="Y" goto :install
|
||||||
goto :cancel
|
goto :cancel
|
||||||
|
|
||||||
:install
|
:install
|
||||||
call :uninstall
|
call :uninstall
|
||||||
copy /Y "%wufuc_dll_fullpath%" "%wufuc_dll_target%" && (
|
copy /Y "%wufuc_dll_fullpath%" "%wufuc_dll_target%" && (
|
||||||
reg add "%regkey%" /v GlobalFlag /t REG_DWORD /d 0x00000100 /f
|
|
||||||
reg add "%regkey%" /v VerifierDlls /t REG_SZ /d "%wufuc_dll%" /f
|
reg add "%regkey%" /v VerifierDlls /t REG_SZ /d "%wufuc_dll%" /f
|
||||||
|
reg add "%regkey%" /v GlobalFlag /t REG_DWORD /d 0x00000100 /f
|
||||||
)
|
)
|
||||||
echo.
|
echo.
|
||||||
echo wufuc has been successfully installed!
|
|
||||||
echo You will need to restart your PC to finish installing wufuc.
|
echo You will need to restart your PC to finish installing wufuc.
|
||||||
goto :confirm_restart
|
goto :confirm_restart
|
||||||
:: END INSTALL MODE
|
:: END INSTALL MODE ///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
:: BEGIN UNINSTALL MODE
|
:: BEGIN UNINSTALL MODE ///////////////////////////////////////////////////////
|
||||||
:confirm_uninstall
|
:confirm_uninstall
|
||||||
if "%UNATTENDED%"=="1" goto :uninstall_stub
|
if "%UNATTENDED%"=="1" goto :uninstall_stub
|
||||||
echo.
|
echo.
|
||||||
@@ -181,7 +160,12 @@ echo You will need to restart your PC to finish uninstalling wufuc.
|
|||||||
goto :confirm_restart
|
goto :confirm_restart
|
||||||
|
|
||||||
:uninstall
|
:uninstall
|
||||||
call :remove_legacy
|
sfc /SCANFILE="%systemroot%\System32\wuaueng.dll"
|
||||||
|
set "wufuc_task=wufuc.{72EEE38B-9997-42BD-85D3-2DD96DA17307}"
|
||||||
|
schtasks /Query /TN "%wufuc_task%" >nul 2>&1 && (
|
||||||
|
schtasks /Delete /TN "%wufuc_task%" /F
|
||||||
|
)
|
||||||
|
rundll32 "%wufuc_dll_fullpath%",RUNDLL32_LegacyUnload
|
||||||
reg query "%regkey%" >nul 2>&1 || (
|
reg query "%regkey%" >nul 2>&1 || (
|
||||||
goto :delete_target
|
goto :delete_target
|
||||||
)
|
)
|
||||||
@@ -197,7 +181,7 @@ if exist "%wufuc_dll_target%" (
|
|||||||
)
|
)
|
||||||
:skip_delete
|
:skip_delete
|
||||||
exit /b
|
exit /b
|
||||||
:: END UNINSTALL MODE
|
:: END UNINSTALL MODE /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
:confirm_restart
|
:confirm_restart
|
||||||
if "%NORESTART%"=="1" goto :die
|
if "%NORESTART%"=="1" goto :die
|
||||||
@@ -206,45 +190,22 @@ echo.
|
|||||||
set /p CONTINUE_RESTART=Enter 'Y' if you would like to restart now:
|
set /p CONTINUE_RESTART=Enter 'Y' if you would like to restart now:
|
||||||
if /I "%CONTINUE_RESTART%"=="Y" goto :restart
|
if /I "%CONTINUE_RESTART%"=="Y" goto :restart
|
||||||
goto :die
|
goto :die
|
||||||
|
|
||||||
:restart
|
:restart
|
||||||
shutdown /r /t 0
|
shutdown /r /t 0
|
||||||
goto :die
|
goto :die
|
||||||
|
|
||||||
:die
|
:die
|
||||||
echo.
|
echo.
|
||||||
|
if "%UNATTENDED%"=="1" (
|
||||||
|
timeout /T 5 /NOBREAK
|
||||||
|
) else (
|
||||||
echo Press any key to exit...
|
echo Press any key to exit...
|
||||||
pause >nul
|
pause >nul
|
||||||
exit
|
)
|
||||||
|
exit /b
|
||||||
|
|
||||||
:cancel
|
:cancel
|
||||||
echo.
|
echo.
|
||||||
echo Canceled by user, press any key to exit...
|
echo Canceled by user, press any key to exit...
|
||||||
pause >nul
|
pause >nul
|
||||||
exit
|
|
||||||
|
|
||||||
:get_filever
|
|
||||||
set "file=%~1"
|
|
||||||
for /f "tokens=*" %%i in ('wmic /output:stdout datafile where "name='%file:\=\\%'" get Version /value ^| find "="') do set "%%i"
|
|
||||||
exit /b
|
|
||||||
|
|
||||||
:remove_legacy
|
|
||||||
sfc /SCANFILE="%systemroot%\System32\wuaueng.dll"
|
|
||||||
set "wufuc_task=wufuc.{72EEE38B-9997-42BD-85D3-2DD96DA17307}"
|
|
||||||
schtasks /Query /TN "%wufuc_task%" >nul 2>&1 && (
|
|
||||||
schtasks /Delete /TN "%wufuc_task%" /F
|
|
||||||
)
|
|
||||||
rundll32 "%wufuc_dll_fullpath%",RUNDLL32_LegacyUnload
|
|
||||||
exit /b
|
|
||||||
|
|
||||||
:set_unattended
|
|
||||||
set "UNATTENDED=%~1"
|
|
||||||
exit /b
|
|
||||||
|
|
||||||
:set_uninstall
|
|
||||||
set "UNINSTALL=%~1"
|
|
||||||
exit /b
|
|
||||||
|
|
||||||
:set_norestart
|
|
||||||
set "NORESTART=%~1"
|
|
||||||
exit /b
|
exit /b
|
17
setup-batch/uninstall_wufuc.bat
Normal file
17
setup-batch/uninstall_wufuc.bat
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@echo off
|
||||||
|
:: Copyright (C) 2017 zeffy
|
||||||
|
|
||||||
|
:: This program is free software: you can redistribute it and/or modify
|
||||||
|
:: it under the terms of the GNU General Public License as published by
|
||||||
|
:: the Free Software Foundation, either version 3 of the License, or
|
||||||
|
:: (at your option) any later version.
|
||||||
|
|
||||||
|
:: This program is distributed in the hope that it will be useful,
|
||||||
|
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
:: GNU General Public License for more details.
|
||||||
|
|
||||||
|
:: You should have received a copy of the GNU General Public License
|
||||||
|
:: along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
call "%~dp0install_wufuc.bat" /UNINSTALL %*
|
@@ -10,9 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
appveyor.yml = appveyor.yml
|
appveyor.yml = appveyor.yml
|
||||||
CONTRIBUTING.md = CONTRIBUTING.md
|
CONTRIBUTING.md = CONTRIBUTING.md
|
||||||
|
setup-batch\install_wufuc.bat = setup-batch\install_wufuc.bat
|
||||||
LICENSE = LICENSE
|
LICENSE = LICENSE
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
setup-batch\setup_wufuc.bat = setup-batch\setup_wufuc.bat
|
setup-batch\uninstall_wufuc.bat = setup-batch\uninstall_wufuc.bat
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
Reference in New Issue
Block a user