Created
June 9, 2020 00:08
-
-
Save sredna/8e7856b724775d843cfb699f29305da3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM | |
REM This "installer/uninstaller" is supposed | |
REM to demostrate a issue with the | |
REM "Automated application uninstall" part | |
REM of WACK. The issue is that WACK | |
REM just uses the UninstallString command | |
REM and this command usually displays a UI | |
REM that requires user interaction. | |
REM It would be nice if WACK could use the | |
REM de facto standar QuietUninstallString | |
REM entry if it exists and fall back to | |
REM UninstallString if it does not. | |
REM | |
REM Because this is just a batch file, you | |
REM have to use cmd.exe as a helper when | |
REM launching the installer in the WACK UI | |
REM and it will fail some of the tests. | |
REM | |
REM ||== Windows App Certification Kit ===_||X=|| | |
REM || || | |
REM || Specify the app to validate || | |
REM || || | |
REM || Setup file: || | |
REM || -------------------------------------- || | |
REM || | c:\windows\system32\cmd.exe | || | |
REM || -------------------------------------- || | |
REM || || | |
REM || Command line: || | |
REM || -------------------------------------- || | |
REM || | /C "C:\temp\WackTestInstaller.cmd" | || | |
REM || -------------------------------------- || | |
REM || || | |
REM || | | Per Machine || | |
REM || || | |
REM || |X| Per user || | |
REM || || | |
REM ||==========================================|| | |
REM | |
setlocal | |
set silent=0 | |
(echo %* | find /I "/SILENT")&&set silent=1 | |
if "%uninstaller%"=="1" goto uninstall | |
REM ========================================== | |
:install | |
if "%silent%"=="1" goto install_silent | |
echo.&echo.Installer:&echo. | |
echo.Press ENTER to install...&REM pause | |
echo.WARNING You forgot to pass /SILENT to the installer, I'll do it for you this time... | |
ping localhost >nul | |
echo. | |
:install_silent | |
set unkey=WackTest%DATE% | |
set instdir=%Temp% | |
echo.Creating uninstaller | |
set unbin=%instdir%\WackTestUninst.cmd | |
> "%unbin%" echo.@echo off | |
>> "%unbin%" echo.setlocal | |
>> "%unbin%" echo.set uninstaller=1 | |
>> "%unbin%" echo.set unkey=%unkey% | |
type "%~0" >> "%unbin%" | |
REM WACK forces us to create a shortcut | |
echo.Creating Start Menu shortcut | |
REM Copy "%appdata%\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" "%appdata%\Microsoft\Windows\Start Menu\Programs\WackTest.lnk" | |
call powershell -NoLogo -NoProfile -Command "$s = ((New-Object -ComObject ('WScript.Shell')).CreateShortcut('%appdata%\Microsoft\Windows\Start Menu\Programs\WackTest.lnk')); $s.TargetPath = 'cmd.exe'; $s.Arguments = '/K echo This is a silly application'; $s.Save()" | |
echo.Registering with ARP | |
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /v UninstallString /d "cmd.exe /C \"%unbin%\"" | |
REM De facto standard QuietUninstallString value that WACK does not use :( | |
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /v QuietUninstallString /d "cmd.exe /C \"%unbin%\" /SILENT" | |
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /v DisplayName /d "Wack Test" | |
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /v InstallLocation /d "%instdir%" | |
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /v Publisher /d "Example.com" | |
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /v DisplayVersion /d "0.1" | |
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /v VersionMajor /d "0" /t REG_DWORD | |
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /v VersionMinor /d "1" /t REG_DWORD | |
echo Done. | |
goto q | |
REM ========================================== | |
:uninstall | |
if "%silent%"=="1" goto uninstall_silent | |
echo.Uninstaller (Unkey=%unkey%) | |
echo.Are you sure you want to uninstall? Press ENTER to continue...&pause | |
:uninstall_silent | |
del "%appdata%\Microsoft\Windows\Start Menu\Programs\WackTest.lnk" | |
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\%unkey%" /f | |
del "%~0" | |
echo Done. | |
goto q | |
REM ========================================== | |
:q | |
@cmd /C verify on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment