@echo off :: Another useful script by Justin Mercier, aka the Troubleshooting Ninja :: set a local scope so we don't clobber any shell settings setlocal :: set a pretty title for our command window title Installing Windows XP Professional Post-SP2 Hotfixes :: this is the directory containing our hotfixes (it can be . for the same directory as this script) set PATHTOFIXES=.\newfixes :: the next two sniff out this script's path and chomps off the trailing slash set SCRIPTPATH=%~dp0 set SCRIPTPATH=%SCRIPTPATH:~0,-1% :: this is the drive to map the script path to if we are not on a local drive set DRIVE=L: :: check to see if we are on a local drive, otherwise call mapdrive echo %SCRIPTPATH% | find ":" || call :mapdrive :: push into the directory pushd %PATHTOFIXES% :: go through each hotfix and install it for %%i in (*.exe) do %%i /QUIET /NORESTART && echo SUCCESS: %%i || echo ERROR: %%i :: ask the user to reboot echo Press any key to reboot or CTRL-C to exit & pause >nul & shutdown -r -t 5 -f :: exit nicely endlocal & popd & goto:EOF :mapdrive :: this is a nice little call function that tries to map the drive letter set above, otherwise exit with error if not exist %DRIVE%\ ( net use %DRIVE% "%SCRIPTPATH%" /persistent:no pushd %DRIVE%\ ) else ( echo cannot map to drive %DRIVE% pause exit 1 )