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

Re: I wrote a new Presetup.cmd file.

Very interesting! Thanks for sharing

@ Jaak & OverFlow
Wouldn't this style of scripting could allow us or anyone making a UWCD able to bypass using $OEM$ so that the 'Repair' option could be retained?? (downside... no cmdline.txt)

Re: I wrote a new Presetup.cmd file.

simply removing the unattended section of a m2 installs winnt.sif will enable repair.
of course you will also have to NOT use ROE method to launch the finisher.

obviously M1 will fail without the unattended section so this could be used in conjunction with M1.
however his code doesn't address an m1 source so i belive it would fail on an m1 source anyway.
however m1 is all but dead atm furthermore m1 doesnt require extraction so dpinst can simply be run.

this is really way to complicated for somthing quite simple and since it fails on an m1 source is maybe not complete. (although presetup.cmd IS specific to M2) most admins know where their files are in advance. if they don't they shouldn't be admins. it is reasonable to expect that the drivers are in a certain folder and it is resonable that we will know in advance where we put that folder. (we may not know which drive letter - but certainly what path is known)  it is a half completed excersise in making a mountain out of a mole hill.

if i were going to custom code this for myself it would be half the size - not twice the size... smaller is faster

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: I wrote a new Presetup.cmd file.

I didn't care to address M1 because I don't use M1. Besides, M1 utilizes the $OEM$ folders, which is what I prefer to avoid. This code wasn't written for DriverPacks, necessarily. I'm offering feedback on how I improved presetup.cmd, and I'm not positing this as a request to add my code to your program (to be honest, I wouldn't want you to do that anyway since that would also likely require my assistance in modifying code in the future).

This also has many more fail-safe methods for individuals that shift their files around and like to customize their layout a bit more than what DriverPacks allows by default. Rather than having to modify Presetup.cmd directly, it will automatically find those files now, which is useful if you're building a disc with multiple operating systems on it (e.g., a universal OEM and VLK disc would require at least two copies of Windows). DriverPacks could also be placed, decompressed, directly on the disc and my script will automatically find the "D\" directory and pass that as an argument into DevPath before running either WatchDSP or DSPdsblr, which I think also means that it supports M1 (but I'm not sure since I don't know anything about M1 other than that the drivers are already decompressed from the 7zip files).

In short, my script is a lot more functional than the one that comes with DriverPacks, and it isn't intended to be "faster" since it serves more use, but at the same time, it will not hang if necessary DriverPacks files are not found. Also, mine has an intuitive log file. That makes mine awesome. big_smile

Re: I wrote a new Presetup.cmd file.

so you wrote a script that can do what the multiboot platform feature in base already does...
and added a log... wink

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: I wrote a new Presetup.cmd file.

Plus it incorporates RogueSpear's naming scheme and doesn't require that I use DriverPacks BASE to do it.

Re: I wrote a new Presetup.cmd file.

I just read your post in that other thread. How dare you berate me with accusations of "diminishing" people's work after your behavior in this discussion.

Re: I wrote a new Presetup.cmd file.

and it did not even occur to you that the two things were related...
reap what you sow... if you desire to be shown respect then show some yourself...
PS I have been in computers since 1968 and was writing programs before you were born.

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: I wrote a new Presetup.cmd file.

twig123 wrote:

Very interesting! Thanks for sharing

@ Jaak & OverFlow
Wouldn't this style of scripting could allow us or anyone making a UWCD able to bypass using $OEM$ so that the 'Repair' option could be retained?? (downside... no cmdline.txt)

I'm currently working on a project to maintain cmdline.txt functionality as well. It would have to be slightly different, however. It would have to be an external program that initiates the cmdlines.txt parsing, and I'd like to have the option of putting the .txt file anywhere on the disc.

I really don't like having $OEM$ folders on my disc. I think they're tacky. I especially don't like having $OEM$\ alongside OEM\ because it looks redundant.

Re: I wrote a new Presetup.cmd file.

i belive you can accomplish this quite easily by useing svcpack.inf

svcpack.inf runs at t-13 (right after cmdlines.txt normaly would at t-12)
You can call a script from svcpack.inf as long as that script is in \I386\svcpack\
so... add a script or exe before any other existing entries IE

[SetupHotfixesToRun]
MyScript.cmd

assumeing that \I386\svcpack\MyScript.cmd exists you could parse the commands that would normaly be in cmdlines.txt at approximately the same time during setup.

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.