Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Snippet for OemPnPDriversPath, setDevicePath clone

- - - - -

  • Please log in to reply
45 replies to this topic

#1
idle.newbie

idle.newbie

    Junior

  • Member
  • Pip
  • 93 posts
  • Joined 01-August 04
OemPnPDriversPath.cmd
@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.


How to remove advertisement from MSFN

#2
Bilou_Gateux

Bilou_Gateux

    Powered by Windows Embedded

  • Member
  • PipPipPipPipPip
  • 768 posts
  • Joined 03-January 04
great ! nice ! wonderfull !
i like cmd scripts.
i will keep this one and try it.

:thumbup

Works perfect but the name you choose for WINNT.SIF in your example is a bit confusing. :wacko:

OemPnPDriversPath.cmd C:\Drivers "C:\UWCD root\i386\WINNT.SIF"


Use 8.3 naming convention for your path and it's more easy.
OemPnPDriversPath.cmd C:\Drivers C:\XPCREATE\CDROOT\i386\WINNT.SIF

Edited by Bilou_Gateux, 09 September 2004 - 09:10 AM.

OS Version = 5.1.2600 Service Pack 3
Platform ID = 2 (NT)
Service Pack = 3.0
Suite = 0x0140
Product Type = 1
Architecture = x86

#3
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag
HUH??? Never seen this script before...

I guess I'll start using this one in my DriverPacks batch files !!!

:thumbup

superb!

#4
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag
I can't get this script to work...

It DOES give output: I find a new WINNT.SIF file in the current directory, with everything in it except the comments. But unfortunately also without OemPnPDriversPath...

How did it work for you Bilou_Gateaux?

#5
Bilou_Gateux

Bilou_Gateux

    Powered by Windows Embedded

  • Member
  • PipPipPipPipPip
  • 768 posts
  • Joined 03-January 04
My %systemdrive% is as described below:

$OEM$ dir
Posted Image

PnPDrvrs dir
Posted Image

UNATTEND.TXT code

Open command prompt in C:\PnPDrvrs:
OEMPnPDriversPath C:\PnPDrvrs C:\$OEM$\UNATTEND.TXT

C:\PnPDrvrs\WINNT.SIF content:
OemPnPDriversPath = "PnPDrvrs\Display\Intel;PnPDrvrs\Display\NVidia;PnPDrvrs\Hdc\Intel;PnPDrvrs\Media\Fujitsu;
***//cut for easy reading//***
PnPDrvrs\Net\BRCM;PnPDrvrs\Net\Intel;PnPDrvrs\System\Intel;PnPDrvrs\Usb\Intel"

OS Version = 5.1.2600 Service Pack 3
Platform ID = 2 (NT)
Service Pack = 3.0
Suite = 0x0140
Product Type = 1
Architecture = x86

#6
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag
For me it is like this:

K:\OemPnPDriversPath.cmd
K:\$OEM$\$1\DP
K:\I386\winnt.sif

And OemPnPDriversPath.cmd has to search for devicepaths in K:\$OEM$\$1\DP, adding them to K:\I386\winnt.sif.

EDIT: but as I said, it doesn't work...

#7
Bilou_Gateux

Bilou_Gateux

    Powered by Windows Embedded

  • Member
  • PipPipPipPipPip
  • 768 posts
  • Joined 03-January 04
The batch file doesn't direct edit your source WINNT.SIF but recreate a new one wich is saved to the dir where you have saved the batch file.

Try first to move the batch file to your DP dir ie K:\$OEM$\$1\DP and then, the resulting new SIF file should be in K:\$OEM$\$1\DP\WINNT.SIF
OS Version = 5.1.2600 Service Pack 3
Platform ID = 2 (NT)
Service Pack = 3.0
Suite = 0x0140
Product Type = 1
Architecture = x86

#8
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag

The batch file doesn't direct edit your source WINNT.SIF but recreate a new one wich is saved to the dir where you have saved the batch file.

I know that... but the one that I find in the current directory doesn't contain the OemPnPDriversPath...

#9
Bilou_Gateux

Bilou_Gateux

    Powered by Windows Embedded

  • Member
  • PipPipPipPipPip
  • 768 posts
  • Joined 03-January 04
OK i have created the same dir tree as you on my D: partition
D:\$OEM$\$1\PnPDrvrs contains all drivers subdirs and OEMPnPDriversPath.cmd

D:\I386 contains the original WINNT.SIF

Open command prompt:
cmd /k cd /d D:\$OEM$\$1\PnPDrvrs
run:
OEMPnPDriversPath D:\$OEM$\$1\PnPDrvrs D:\I386\WINNT.SIF

and check the result (new WINNT.SIF) in D:\$OEM$\$1\PnPDrvrs
OemPnPDriversPath = "$OEM$\$1\PnPDrvrs\Display\Intel;$OEM$\$1\PnPDrvrs\Display\NVidia;$OEM$\$1\PnPDrvrs\Hdc\Intel;$OEM$\$1\PnPDrvrs\Media\Fujitsu;$OEM$\$1\PnPDrvrs\Net\BRCM;$OEM$\$1\PnPDrvrs\Net\Intel;$OEM$\$1\PnPDrvrs\System\Intel;$OEM$\$1\PnPDrvrs\Usb\Intel"

But the solution is not clean as having the PnP Drivers dir on root of harddrive to build the OemPnPDriversPath =
Compare the result with my previous post.
I suggest to first build the winnt.sif with your DP dir in root of hard drive and then move to the subdir you want ie $OEM$\$1
OS Version = 5.1.2600 Service Pack 3
Platform ID = 2 (NT)
Service Pack = 3.0
Suite = 0x0140
Product Type = 1
Architecture = x86

#10
Afterdawn

Afterdawn

    Member

  • Member
  • PipPip
  • 179 posts
  • Joined 04-November 04
Hmm too bad... I thougt your script changed it at runtime! I'm still working on a script that automatically updates the path in the t-39 stage. Thus as a attached program! Actually exactly the same as Pyron's SetDevicePath.exe, but I want it as an cmd-script!
I went to the doctor the other day and he said I was a paranoid schizophrenic... Well, he didn't actually say it, but we know what he was thinking.

#11
Bilou_Gateux

Bilou_Gateux

    Powered by Windows Embedded

  • Member
  • PipPipPipPipPip
  • 768 posts
  • Joined 03-January 04
The author is idle.newbie

Yes, it would be fine to dynamically update the WINNT.SIF at T-39.
OS Version = 5.1.2600 Service Pack 3
Platform ID = 2 (NT)
Service Pack = 3.0
Suite = 0x0140
Product Type = 1
Architecture = x86

#12
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag

Actually exactly the same as Pyron's SetDevicePath.exe, but I want it as an cmd-script!

Why do you want a cmd file so badly, if the executable has been confirmed working by so many?

#13
Afterdawn

Afterdawn

    Member

  • Member
  • PipPip
  • 179 posts
  • Joined 04-November 04

Actually exactly the same as Pyron's SetDevicePath.exe, but I want it as an cmd-script!

Why do you want a cmd file so badly, if the executable has been confirmed working by so many?

Well, maybe hard to explain, but I'll try:

I just like to have something that I know HOW it works. Just out of curiosity, and to be assured that it does what I think it does. Also, I might want to add/modify some things, every now and then.
I went to the doctor the other day and he said I was a paranoid schizophrenic... Well, he didn't actually say it, but we know what he was thinking.

#14
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag

Well, maybe hard to explain, but I'll try:

I just like to have something that I know HOW it works. Just out of curiosity, and to be assured that it does what I think it does.

I understand you, I'm the same. But if I see that something has been working for hundreds of people, then I'll gladly use it...

#15
Afterdawn

Afterdawn

    Member

  • Member
  • PipPip
  • 179 posts
  • Joined 04-November 04
This script is nice btw, but I'd wonder why he didn't use a utility to update the winnt.sif.

That way he could replace the whole :RECREATE routine into this line:
nircmd inisetval "d:\xp_unattend\I386\winnt.sif" "Unattended" "OemPnPDriversPath" "~qTHIS_IS_THE_NEW_VALUE~q"

http://www.nirsoft.n...ils/nircmd.html
I went to the doctor the other day and he said I was a paranoid schizophrenic... Well, he didn't actually say it, but we know what he was thinking.

#16
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag

This script is nice btw, but I'd wonder why he didn't use a utility to update the winnt.sif.

That way he could replace the whole :RECREATE routine into this line:

nircmd inisetval "d:\xp_unattend\I386\winnt.sif" "Unattended" "OemPnPDriversPath" "~qTHIS_IS_THE_NEW_VALUE~q"

http://www.nirsoft.n...ils/nircmd.html

And does that work? If it does, I'll use that...

EDIT: the syntax inisetval isn't listed? :o

Edited by Bâshrat the Sneaky, 05 February 2005 - 02:34 PM.


#17
Afterdawn

Afterdawn

    Member

  • Member
  • PipPip
  • 179 posts
  • Joined 04-November 04
Okay, I created my own, and this one definitely works for me. Just modify the 3 values in the begin of my script. The driver_prefix is just the name that should be prefixed for every folder that contains an INF-file.
The drivers_path and winnt_file should be surrounded by quotes if you have spaces in your path. Make sure you've downloaded nircmd.
@echo off

set drivers_path=D:\xp_unattend\$oem$\$1\drivers
set drivers_prefix=drivers
set winnt_file=D:\xp_unattend\i386\winnt.sif

call :traverse %drivers_path% %drivers_prefix%
nircmd.exe inisetval %winnt_file% "Unattended" "OemPnPDriversPath" "~q%newPath%~q"
goto :eof


:traverse
  pushd %~f1
  if EXIST *.inf (
    if NOT DEFINED newPath (
      set newPath=%~2
    ) else (
      call set newPath=%%newPath%%;%~2
    )
  )
  for /d %%I in (*) do (
    call :traverse "%%I" "%2\%%I"
  )
  popd
goto :eof

Edited by Afterdawn, 05 February 2005 - 04:42 PM.

I went to the doctor the other day and he said I was a paranoid schizophrenic... Well, he didn't actually say it, but we know what he was thinking.

#18
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag
I'll test it immediately!

EDIT: AT LAST some results!!!! Superb :)

2 questions:

[FIXED] 1) is it case-sensitive for the inf file? I assume yes? How to solve it? Simply add the same but then replace *.inf by *.INF?
>> It ISN'T case-sensitive!!!

[FIXED] 2) Isn't it possible to make it no longer required to enter the full path?
>>You CAN use relative path, if nircmd.exe and the cmd file are on top of both the driversfolder and the I386 folder!



I LOVE YOU :thumbup :wacko: :blink:

Have been searching on this a very long time!

Edited by Bâshrat the Sneaky, 05 February 2005 - 04:29 PM.


#19
Afterdawn

Afterdawn

    Member

  • Member
  • PipPip
  • 179 posts
  • Joined 04-November 04

I'll test it immediately!

EDIT: AT LAST some results!!!! Superb :)

2 questions:

[FIXED] 1) is it case-sensitive for the inf file? I assume yes?  How to solve it? Simply add the same but then replace *.inf by *.INF?
>> It ISN'T case-sensitive!!!

[FIXED] 2) Isn't it possible to make it no longer required to enter the full path?
>>You CAN use relative path, if nircmd.exe and the cmd file are on top of both the driversfolder and the I386 folder!



I LOVE YOU  :thumbup  :wacko:  :blink:

Have been searching on this a very long time!

Okay good to hear that it finally works for you now!

And you're right, the winnt.sif file can be relative!
I went to the doctor the other day and he said I was a paranoid schizophrenic... Well, he didn't actually say it, but we know what he was thinking.

#20
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag

nircmd.exe inisetval %winnt_file% "Unattended" "OemPnPDriversPath" "~q%newPath%~q"

I need to apply this piece of code somewhere else as well..

I've searched the net, but couldn't find anything about the '~q' you used... What is it for???

Can you please verify this piece of code?

SET %D%=DriverPack
SET %G%=Graphics
SET %S%=Sound
SET %IE%=IF EXIST

ROBOCOPY M%M% "%CD%" *.* /E /MOV /NS /NC /NFL /NDL /NP /NJH /NJS
%IE% I386\presetup.cmd (
%IE% OEM\%D%_%G%_V*.7z nircmd.exe inisetval I386\winnt.sif "GUIRunOnce" "command7" "~q%IE% %SYSTEMDRIVE%\DP\G\%G%_Control_Panels.cmd %SYSTEMDRIVE%\DP\G\%G%_Control_Panels.cmd~q"
%IE% OEM\%D%_%S%_V*.7z nircmd.exe inisetval I386\winnt.sif "GUIRunOnce" "command7" "~q%IE% %SYSTEMDRIVE%\DP\S\%S%_Control_Panels.cmd %SYSTEMDRIVE%\DP\S\%S%_Control_Panels.cmd~q"
) ELSE (
%IE% $OEM$\$1\DP\G\%G%_Control_Panels.cmd nircmd.exe inisetval I386\winnt.sif "GUIRunOnce" "command8" "~q%IE% %SYSTEMDRIVE%\DP\G\%G%_Control_Panels.cmd %SYSTEMDRIVE%\DP\G\%G%_Control_Panels.cmd~q"
%IE% $OEM$\$1\DP\S\%S%_Control_Panels.cmd nircmd.exe inisetval I386\winnt.sif "GUIRunOnce" "command8" "~q%IE% %SYSTEMDRIVE%\DP\S\%S%_Control_Panels.cmd %SYSTEMDRIVE%\DP\S\%S%_Control_Panels.cmd~q"
)
ECHO.
ECHO _ commands added to winnt.sif to install %D% %G%/%S% control panels...
)

Note: I can guarantee you that all required files are present, please just verify the (syntax of) the code!

Thanks!

#21
sixpack

sixpack

    Senior Member

  • Member
  • PipPipPipPip
  • 515 posts
  • Joined 29-May 04
~q = Double-quote character: "

Example:
infobox "This is the first line~n~qThis is a second line, in quotes~q" "Example"
The above example displays a message-box containing 2 lines.

from the help file
Never say, "Oops!" always say, "Ah, interesting!"

#22
Afterdawn

Afterdawn

    Member

  • Member
  • PipPip
  • 179 posts
  • Joined 04-November 04
@ Bâshrat the Sneaky

The ~q makes sure that the entry added to OemPnpDriversPath is surrounded by double quotes... just like it should be.

The help for NIRCMD is contained in the Help file that's included!

About your script.. it's very difficult to see what's it doing / supposed to do.

Can't you just tell what you want... and then I could tell you how I should do it!
I went to the doctor the other day and he said I was a paranoid schizophrenic... Well, he didn't actually say it, but we know what he was thinking.

#23
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag

@ Bâshrat the Sneaky

The ~q makes sure that the entry added to OemPnpDriversPath is surrounded by double quotes... just like it should be.

The help for NIRCMD is contained in the Help file that's included!

About your script.. it's very difficult to see what's it doing / supposed to do.

Can't you just tell what you want... and then I could tell you how I should do it!

Well, in fact it's very easy: if a certain file exists, nircmd adds some values to the winnt.sif file.

'visual' explanation:

IF method 2 (
if driverpack graphics M2 nircmd blabla
if driverpack sound M2 nircmd blabla
) else (
if driverpack graphics M1 nircmd blabla
if driverpack sound M1 nircmd blabla
)

I looked in that helpfile, but only ~$ is mentioned there!


@sixpack: thanks for the explanation! :)

#24
Afterdawn

Afterdawn

    Member

  • Member
  • PipPip
  • 179 posts
  • Joined 04-November 04
I must admit that the code isn't very clear! Replacing IF EXIST by %IE% isn't really helpfull IMHO.

Why don't you use clear syntax with indents.. something like your "visual code":

if exist (%file%) (
  if exist (%graphics_dp%) (
     graphics_dp.cmd
  )
  if exist (%lan_dp%) (
     lan_dp.cmd
  )
  nircmd BLA BLA BLA
) else (
  ETCETERA...
)

I went to the doctor the other day and he said I was a paranoid schizophrenic... Well, he didn't actually say it, but we know what he was thinking.

#25
Bâshrat the Sneaky

Bâshrat the Sneaky

    aka Wim Leers

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,214 posts
  • Joined 29-October 03
  • OS:none specified
  • Country: Country Flag
Hmm... maybe... but I like shorter code... But you're completely right when you're saying it'd be better for the clarity....




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN