Topic: I wrote a new Presetup.cmd file.
I figured I would share it with anyone that is interested.
Here's what it does:
If the files cannot be found (let's say you put your DP*.7z files in %CdDrive%\DriverPacks\ or something), it will automatically search elsewhere on the CD and SystemDrive for the files, and it should successfully find them in .\DriverPacks. If they still cannot be found, it will not attempt to unzip them. Additionally, it is a bit more intelligent when it comes to seeking the CdDrive, and will use the parent directory as the CdDrive if the tag file is not found.
Why I created it:
I use Presetup for purposes other than driver packs. I primarily use it to extract files to the SystemDrive and SystemRoot using RogueSpear's naming scheme (000_SD*.7z and 000_SR*.7z, accordingly). For example, I extract all of my Windows themes, backgrounds, screensavers, and standalone executables via the Presetup method. I do this because it allows me to utilize 7zip compression while maintaining the same functionality as the $OEM$ sub-directories.
Additional notes:
A log file named "Presetup.log" is created in SystemRoot letting you know what tasks were executed.
If you want to modify it, I suggest just following the same syntax I've used for using Calls as pseudo-functions.
Works perfect for me using WinXP Pro SP3 build 5512.
Presetup.cmd
@Echo Off
Echo.
If Exist "%systemroot%\system32\setupold.exe" Del /F "%systemroot%\system32\setupold.exe"
Set TAG=\WIN51
For %%i In (C D E F G H I J K L M N O P Q R S T U V W X Y Z) Do If Exist "%%i:%TAG%" Set CdDrive=%%i:
If NOT DEFINED CdDrive Set CdDrive=%CD%\..\
Set OemDir=%CdDrive%\OEM
If NOT Exist "%OemDir%" FindFile "\OEM" OemDir "%CdDrive%"
Call :Presetup>"%SystemRoot%\presetup.log"
If NOT DEFINED DPDIR Goto :EOF
If NOT DEFINED WDSP Goto :EOF
"%SDP%" "%DPDIR%"
Start "" "%WDSP%"
Goto :EOF
Exit
:Presetup
@Call :FindFile "7z.exe" "s7z"
@Call :FindFile "un7zip.exe" "un7zip"
@Call :FindFile "DPsFnshr.ini" "DPsFnshr"
@Call :FindFile "DP*.7z" "DP"
@Call :FindFile "000_SR*.7z" "SR"
@Call :FindFile "000_SD*.7z" "SD"
@Call :FindFile "*.ins" "ins"
If DEFINED s7z @Call :CopyFile "%s7z%" "%SystemRoot%\system32\"
If DEFINED DPsFnshr @Call :CopyFile "%DPsFnshr%" "%SystemDrive%\"
If DEFINED ins @Call :CopyFile "%ins%" "%SystemDrive%\"
If Exist "%OemDir%\bin\*.7z" @Call :unZip "%OemDir%\bin\*.7z" "%SystemDrive%\"
If DEFINED SR @Call :unZip "%SR%" "%SystemRoot%\"
If DEFINED "%SD%" @Call :unZip "%SD%" "%SystemDrive%\"
If DEFINED "%DP%" @Call :unZip "%DP%" "%SystemDrive%\"
@Call :FindFile "DevPath.exe" "SDP"
If Exist "%SystemDrive%\DSPdsblr.exe" Set WDSP=%SystemDrive%\DSPdsblr.exe
If NOT DEFINED WDSP If Exist "%SystemDrive%\WatchDSP.exe" Set WDSP=%SystemDrive%\WatchDSP.exe
@Call :FindFile "WatchDSP.exe" "WDSP"
@Call :FindFile "DSPdsblr.exe" "WDSP"
@Call :FindFile "D\*" "DPDIR"
Set
Goto :EOF
:unZip %1 %2
If DEFINED s7z Set unZip="%s7z%" x -y -aoa %1 -o%2
If DEFINED un7zip Set unZip="%un7zip%" %1 %2
@Echo Unzipping %1 to %2
If Exist %2 If Exist %1 %unZip%
If %ErrorLevel% GTR 0 @Echo: ...Could not extract!
Goto :EOF
:CopyFile %1 %2
If Exist %1 Copy /V /Y %1 "%~2\" 1>Nul
If NOT Exist "%~2\%~nx1" @Echo: ...File did not copy!
Goto :EOF
:FindFile %1 %2 %3
@REM * Call :FindFile "searchTerm" "OutputVariable"
@REM * Note: "searchTerm" may contain wildcards.
If [%3]==[] (
Echo Searching for ^<%~1^>
@Call :FindFile %1 %2 "%SystemDrive%"
If DEFINED %~2 Goto :EOF
@Call :FindFile %1 %2 "%OemDir%"
If DEFINED %~2 Goto :EOF
@Call :FindFile %1 %2 "%OemDir%\bin"
If DEFINED %~2 Goto :EOF
@Call :FindFile %1 %2 "%CdDrive%"
If DEFINED %~2 Goto :EOF
@Echo: ...File not found!
Goto :EOF
)
Pushd %3
If Exist "%~3\%~1" Set %~2=%~3\%~1
For /F "tokens=1 delims=" %%A In ('Dir /a-d /b /s "%~1" 2^>nul ^| FIND /C /V ""') Do Set Num=%%A
Set fType=unknown
If %Num% EQU 1 (Set fType=findFile)
If %Num% GTR 1 (Set fType=findDir)
If %Num% EQU 0 (
For /F "tokens=1 delims= " %%A In ('Dir /ad /s "%~1" 2^>nul ^| Find "Dir(s)"') Do (
If %%A GTR 1 (Set fType=dir)
)
)
Echo %1 | FindStr /L /I /C:"*" >Nul
If %ErrorLevel% EQU 0 Set fType=findDir
If [%fType%]==[findDir] (
If Exist "%~3\%~1" (
Set %~2=%~3\%~1
Goto :EOF
)
For /R "%CD%" %%A In (%~1) Do (
If Exist "%%~dpA\%~1" Set %~2=%%~dpA
Echo %1 | FindStr /L /I /C:"*" >Nul
If %ErrorLevel% EQU 0 Set %~2=%%~dpA\%~1
)
)
If [%fType%]==[findFile] (
For /R "%CD%" %%A In (%~1) Do (
If Exist "%%~A" Set %~2=%%~A
)
)
If [%fType%]==[dir] (
Set %~2=%CD%\%~1
)
Popd
Goto :EOF