Jump to content

A new PRESETUP.CMD


RogueSpear

Recommended Posts

After getting tired of juggling different scripts and files for different installs, I've started to make all of my scripts, batches, etc. flexible and modular. So here's the PRESETUP.CMD file that I came up with:

SET TAG=\WIN51IP.SP2
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:
SET OEM=%CDDRIVE%\OEM

IF EXIST %OEM%\7za.exe Copy %OEM%\7za.exe %SYSTEMROOT%\system32\7za.exe

IF EXIST %OEM%\D*.7z 7za.exe x -y -aoa %OEM%\D*.7z -o%SYSTEMDRIVE%
IF EXIST %SYSTEMDRIVE%\D*.7z 7za.exe x -y -aoa %SYSTEMDRIVE%\D*.7z -o%SYSTEMDRIVE%
IF EXIST %SYSTEMDRIVE%\D*.7z DEL %SYSTEMDRIVE%\D*.7z
IF EXIST %OEM%\000_SR*.7z 7za.exe x -y -aoa %OEM%\000_SR*.7z -o%SYSTEMROOT%
IF EXIST %SYSTEMDRIVE%\000_SR*.7z 7za.exe x -y -aoa %SYSTEMDRIVE%\000_SR*.7z -o%SYSTEMROOT%
IF EXIST %SYSTEMDRIVE%\000_SR*.7z DEL %SYSTEMDRIVE%\000_SR*.7z
IF EXIST %OEM%\000_SD*.7z 7za.exe x -y -aoa %OEM%\000_SD*.7z -o%SYSTEMDRIVE%
IF EXIST %SYSTEMDRIVE%\000_SD*.7z 7za.exe x -y -aoa %SYSTEMDRIVE%\000_SD*.7z -o%SYSTEMDRIVE%
IF EXIST %SYSTEMDRIVE%\000_SD*.7z DEL %SYSTEMDRIVE%\000_SD*.7z

IF EXIST %OEM%\SetDevicePath.exe SET SDP=%OEM%\SetDevicePath.exe
IF EXIST %SYSTEMDRIVE%\SetDevicePath.exe SET SDP=%SYSTEMDRIVE%\SetDevicePath.exe
IF EXIST %OEM%\DevPath.exe SET SDP=%OEM%\DevPath.exe
IF EXIST %SYSTEMDRIVE%\DevPath.exe SET SDP=%SYSTEMDRIVE%\DevPath.exe
IF EXIST %OEM%\WatchDriverSigningPolicy.exe SET WDSP=%OEM%\WatchDriverSigningPolicy.exe
IF EXIST %SYSTEMDRIVE%\WatchDriverSigningPolicy.exe SET WDSP=%SYSTEMDRIVE%\WatchDriverSigningPolicy.exe
IF EXIST %OEM%\WatchDSP.exe SET WDSP=%OEM%\WatchDSP.exe
IF EXIST %SYSTEMDRIVE%\WatchDSP.exe SET WDSP=%SYSTEMDRIVE%\WatchDSP.exe
IF EXIST %CDDRIVE%\D SET DP=%CDDRIVE%\D
IF EXIST %SYSTEMDRIVE%\D SET DP=%SYSTEMDRIVE%\D

%SDP% %DP%
START %WDSP%

You can execute your installs in the following ways:

  • Method 2 install where you decompress the DriverPack .7z files to the %SystemDrive%. The DriverPack .7z files can be located either in the \OEM directory of your CD/DVD or in the root of your %SystemDrive% in the case of a RIS install.
  • Perform the first half of a Method 1 slipstream and then put the \D directory right on your DVD.
  • Put SetDevicePath.exe and WatchDriverSigningPolicy.exe in either location as well. It doesn't matter which location they're in, it will work.
  • I also put in functionality to decompress 7-Zip archives to %SystemDrive% and to %SystemRoot% from the presetup.cmd file. If they are located on the %SystemDrive%, they will be deleted after decompressing.
  • If the DriverPack .7z archive files are located in %SystemDrive% they will be deleted after decompressing.

Update 03312006

If the DriverPack .7z archive files are located in %SystemDrive% they will be deleted after decompressing.

Update 04112006

Now supports wildcard for decompressing archives to %SystemDrive% and %SystemRoot%. I found this made it easier for me with all of the different setups I have to maintain. As an example, you could have 000_WinDir.7z that you use in all installations, but then also have 000_WinDir-Work.7z and 000_WinDir-Home.7z for differing installs. With support for wildcards you can now just pick and choose as many or few as you want to include in your source.

Update 04212006

It appears that there has been movement in making everything 8.3 compliant for those wanting to execute their unattended installs from winnt.exe. So I made a few changes to try and further that trend of compatibility. For the extra 7z archives, I changed the names replacing the previous long names with SR (SystemRoot) and SD (SystemDrive).

PRESETUP.7z

Edited by RogueSpear
Link to comment
Share on other sites


I'm a bit thick when it comes to scripting...

What does the TAG mean? Could you elaborate a bit?

I see you put:

IF EXIST %OEM%\7za.exe Copy %OEM%\7za.exe %SYSTEMROOT%\system32\7za.exe

Isn't it enough to put the 7za.exe in $OEM$\$$\system32 ?

"7za.exe x -y -aoa"

What does the -aoa argument do?

IF EXIST %CDDRIVE%\D SET DP=%CDDRIVE%\D
IF EXIST %SYSTEMDRIVE%\D SET DP=%SYSTEMDRIVE%\D

%SDP% %DP%

What's that "D" doing there?

Only asking...

Link to comment
Share on other sites

This TAG is to detect under which letter you have CDROM driver. On all XP CD's with SP2 integrated WIN51IP.SP2 file is in the root of the cd. So first and second line are for setting the drive letter of your windows CD.

IF EXIST %OEM%\7za.exe Copy %OEM%\7za.exe %SYSTEMROOT%\system32\7za.exe

This code makes sure the 7za.exe exists in %OEM% dir on CD.. if it does it copies the right things into right dirs. If it doesn't it just skips it. It's to make sure that if you don't use the 7za.exe or you're not going to include it you don't have to change any code here.

The rest i don't realy wanna predict what author had in mind :)

Link to comment
Share on other sites

To be totally honest, I have no idea what "-aoa" denotes. I first saw it probably two years ago and it's always worked for me. So I figured why break it :P

When you decompress the DriverPack .7z files to your hard drive, they end up in directory off the root of %SystemDrive% called D. So most of the time you're going to end up with C:\D. The script allows for you to have the drivers already decompressed, but residing in the root of your CD/DVD, thus the line %CDDRIVE%\D.

I do so many different kinds of installations and I do in fact use CD, DVD, and RIS (not all at once obviously). It just started to get cumbersome managing different files for different installs, so I've started to make everything modular, autodetecting, etc.

Link to comment
Share on other sites

Switches for 7za.exe ;)

-aoa Overwrite All existing files without prompt.

-aos Skip extracting of existing files.

-aou auto rename extracting file (for example, name.txt will be renamed to name_1.txt).

-aot auto rename existing file (for example, name.txt will be renamed to name_1.txt).

Link to comment
Share on other sites

This is untested, and therefore only for idea purposes, but why all that code. I was just thinking that you could do without copying the file over and code it to use one or the other locations a little smarter.

@ECHO OFF &SETLOCAL
SET "TAG=WIN51"
FOR /F %%? IN ('MOUNTVOL^|FIND ":\"') DO (IF EXIST %%?%TAG% (SET OEM=%%?OEM))
PUSHD %OEM%||PUSHD %SYSTEMDRIVE%
FOR %%? IN (7ZA SETDEVICEPATH WATCHDRIVERSIGNINGPOLICY) DO (IF NOT EXIST %%?.EXE (GOTO :EOF))
FOR /F %%? IN ("*DRIVE*.7Z") DO (7ZA.EXE X -Y -AOA %%? -O%SYSTEMDRIVE%)
7ZA.EXE X -Y -AOA %SYSTEMDRIVE%\000_WINDIR.7Z -O%SYSTEMROOT%
FOR %%? IN (000_ DRIVE) DO (IF EXIST %SYSTEMDRIVE%\%%?*.7Z DEL %SYSTEMDRIVE%\%%?*.7Z)
SETDEVICEPATH %~d0\D
START WATCHDRIVERSIGNINGPOLICY

<Edit>

Updated hopefully to match latest update above

</Edit>

Edited by Yzöwl
Link to comment
Share on other sites

I'm not sure what you're getting at there, but I'll attempt to reason things out. With RIS installs, you're not using a CD or DVD. I suppose technically you could pop one in there, but that would defeat half the purpose of RIS itself. So all of your files need to be placed in $OEM$\$1 in order to make it to the hard disk. So you need to look for SetDevicePath.exe and WatchDriverSigningPolicy.exe in both places.

It seems like introducing For loops, to what is otherwise a fairly straightforward script, is unnecessary. And I doubt it would improve performance to any noticeable degree. Like I said, I'm trying to cover all the possible scenarios that I either use or have run across.

Link to comment
Share on other sites

  • 2 weeks later...

Update 04112006

Now supports wildcard for decompressing archives to %SystemDrive% and %SystemRoot%. I found this made it easier for me with all of the different setups I have to maintain. As an example, you could have 000_WinDir.7z that you use in all installations, but then also have 000_WinDir-Work.7z and 000_WinDir-Home.7z for differing installs. With support for wildcards you can now just pick and choose as many or few as you want to include in your source.

Link to comment
Share on other sites

  • 2 weeks later...

Update 04212006

It appears that there has been movement in making everything 8.3 compliant for those wanting to execute their unattended installs from winnt.exe. So I made a few changes to try and further that trend of compatibility. For the extra 7z archives, I changed the names replacing the previous long names with SR (SystemRoot) and SD (SystemDrive).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...