@ECHO OFF
IF "%1"=="" GOTO EOF
IF NOT EXIST %1 GOTO EOF
IF "%2"=="" GOTO EOF
IF NOT EXIST %2 GOTO EOF
SETLOCAL ENABLEDELAYEDEXPANSION
SET OemPnPDriversPath=$
SET STDOUT=WINNT.SIF
TYPE>%STDOUT% 2>NUL
::traverse drivers path
CALL :TRAVERSAL %1
ECHO %OemPnPDriversPath:~2%
::recreate winnt.sif
CALL :RECREATE %2 %STDOUT% Unattended OemPnPDriversPath "%OemPnPDriversPath:~2%"
GOTO EOF
:TRAVERSAL
PUSHD %1
IF EXIST *.INF SET OemPnPDriversPath=!OemPnPDriversPath!;%CD:~3%
FOR /F %%I IN ('DIR /AD /OGN /B') DO (
CALL :TRAVERSAL %CD%\%%I
)
POPD
GOTO EOF
:RECREATE
::%1=Source, %2=Destination, %3=Section, %4=Key, %5=Value
SET SECTION=NO
SET KEY=NO
FOR /F "usebackq tokens=1,2*" %%I IN ("%1") DO (
IF "%%J"=="=" (
IF /I "%%I"=="%4" (
ECHO %4 = %5>>%2
SET UPDATED=YES
) ELSE (
ECHO %%I %%J %%K>>%2
)
) ELSE (
IF /I "%%I"=="[%3]" (
SET SECTION=YES
) ELSE (
IF NOT "%SECTION%"=="NO" (
IF "%KEY%"=="NO" (
ECHO %4 = %5>>%2
SET KEY=YES
)
SET KEY=NO
)
)
ECHO.>>%2
ECHO %%I>>%2
)
)
GOTO EOF
:EOF
It's a Pyron's SetDevicePath.exe clone in .cmd batch scripting, a modified version of my Detached.cmd. It scans every directories under where you specified, looking for *.inf, and write corresponding OemPnPDriverPath entry into WINNT.SIF.
It needs two arguments, #1 full-path to your drivers' directory, #2 your WINNT.SIF.
1.copy/extract every drivers to where it should be. eg:
XCOPY "C:\UWCD root\$OEM$\$1\Drivers" C:\Drivers or 7za x Drivers_MassStorage.7z -y -oC:\
2.run the script.
OemPnPDriversPath.cmd C:\Drivers "C:\UWCD root\i386\WINNT.SIF"
note:
1.pretty your WINNT.SIF, make sure every "=" between key/value pair has space before/after it. eg:
OemPreinstall = Yes
You can do this with RegExp capable text editor like EmEditor, replace all "^(\s*;?\s*\w+)\s*=\s*" with "\1 = ".
2.do not run this .cmd inside i386, or your WINNT.SIF will be empty, 'cause output WINNT.SIF is on current directory.



Help

Back to top











