Created
September 12, 2014 20:52
-
-
Save heaths/74107dfb680f847b78c4 to your computer and use it in GitHub Desktop.
Fix Package Cache to Install Updates
This file contains 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 Copyright (c) Microsoft Corporation. All rights reserved. | |
REM Licensed under the Apache License, Version 2.0 (the "License"); you may not use | |
REM this file except in compliance with the License. You may obtain a copy of the | |
REM License at http://www.apache.org/licenses/LICENSE-2.0 | |
REM | |
REM THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
REM KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | |
REM WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | |
REM MERCHANTABLITY OR NON-INFRINGEMENT. | |
REM | |
REM See the Apache Version 2.0 License for specific language governing permissions | |
REM and limitations under the License. | |
REM setlocal enabledelayedexpansion enableextensions | |
REM Visit http://aka.ms/fakecache for more information. | |
:parse | |
if "%1"=="" goto :run | |
if /i "%1"=="/n" (set NOACT=1) & goto :shl | |
if /i "%1"=="-n" (set NOACT=1) & goto :shl | |
:shl | |
shift | |
goto :parse | |
:run | |
for /f "usebackq tokens=1-3*" %%i in (`reg query hklm\software\microsoft\windows\currentversion\uninstall /s /reg:32`) do ( | |
set TOK=%%i | |
if "!TOK:~0,4!"=="HKEY" ( | |
set KEY=!TOK! | |
set VER= | |
set EXE= | |
) else if "!TOK!"=="BundleVersion" ( | |
set VER=%%k | |
if not "!EXE!"=="" call :write !EXE! | |
) else if "!TOK!"=="UninstallString" ( | |
REM If the path contained any spaces make sure we get it all. | |
set EXE=%%k %%l | |
if not "!VER!"=="" call :write !EXE! | |
) | |
if errorlevel 1 exit /b %ERRORLEVEL% | |
) | |
exit /b %ERRORLEVEL% | |
:write | |
REM Pass path as argument to get just the quoted file name. | |
set DIR=%~dp1 | |
set EXE=%~f1 | |
if not exist "%EXE%" ( | |
if not "%NOACT%"=="1" ( | |
echo Creating: "%EXE%" | |
if not exist "%DIR%" mkdir "%DIR%" > nul 2>&1 | |
REM nslookup is benign and returns success when passed /uninstall | |
copy "%SystemRoot%\System32\nslookup.exe" "%EXE%" > nul | |
) else echo Would create: "%EXE%" | |
) | |
exit /b %ERRORLEVEL% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment