Jump to content

Recommended Posts

Posted (edited)

I've been working on my unattended install CD and was getting frustrated with having to type out the OemPnPDriversPath line in my Winnt.sif file (I have a lot of drivers for my machines). I thought that it would be nice to have a tool that would parse my drivers tree and do it for me.

So, I wrote this VBscript. It's pretty simple and not the most elaborate, but it gets the job done for me and I thought I'd offer it up here in case anyone else can find it usefull.

The script will need to be in the root of you "XPCD" folder, as it bases everything off of this starting point. What it will do is locate itself in this folder, and then look in the $OEM$\$1\Drivers folder and cycle through all the sub-folders located there. It writes out the OemPnPDriversPath line into a file called "Drivers Path.txt" located in the root of the "XPCD" folder. Just cut and paste this into your Winnt.sif and you should be good to go.

Where your "XPCD" folder is doesn't matter, nor does the name. The script will look for itself and then use that as a starting point. Not the strongest logic, but it works. The script is simple enough that if you want to put it in your $OEM$ folder, the changes are pretty straight forward to make it work.

Anyway, feel free to play with it all you want.

Thanks

Mike

Const ForAppending = 8

Set FSO = CreateObject("Scripting.FileSystemObject")
Set objFile = FSO.GetFile("Drivers Path.vbs")
RootFldr = FSO.GetParentFolderName(objFile)
'WScript.Echo RootFldr
SysDrvFldr = RootFldr & "\$OEM$\$1\"
'WScript.Echo SysDrvFldr
DrvrFldr = SysDrvFldr & "Drivers"
'WScript.Echo DrvrFldr
L1 = Len(SysDrvFldr)

Set objTextFile = FSO.CreateTextFile(RootFldr & "\Drivers Path.txt")
objTextFile.Close
Set objTextFile = FSO.OpenTextFile(RootFldr & "\Drivers Path.txt", ForAppending, True)
objTextFile.Write "OemPnPDriversPath=" & chr(34)

ShowSubfolders FSO.GetFolder(DrvrFldr)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
L2 = Len(Subfolder.Path)
StartPnt = L1 + 1
'WScript.Echo StartPnt
StrLenth = L2 - L1
'WScript.Echo StrLenth
DrvPath = Mid(Subfolder.Path,StartPnt,StrLenth)
'Wscript.Echo DrvPath
objTextFile.Write DrvPath & ";"' & vbCtlr
ShowSubFolders Subfolder
Next
End Sub

objTextFile.Write Chr(34)
objTextFile.Close

PS - I've modified the code to fix the typos found.

Edited by mmarable

Posted

I have 2 suggestions for this script;

check for the existance if .inf files before adding a directory to the file

replace the 68 in the following line with a variable determined earlier in the script

DrvPath = Mid(Subfolder.Path,68,StrLenth)
Posted

Thanks for finding the type Bezalel. I'll fix that and see what I can do about checking for the INFs before adding the folder to the list.

Thanks

Posted

When I run the script I get

OemPnPDriversPath=";;;;;;;;;;;;nXP;;;;;;;;;;;;;XP;XP\DATA;;;;;;;;;;;;;;;;;"

Posted

Try replacing the line:

DrvPath = Mid(Subfolder.Path,68,StrLenth)

with:

DrvPath = Mid(Subfolder.Path,Len(SysDrvFldr),StrLenth)

You might get an off by 1 error but its easily fixed.

Posted

@Bezalel

Thanks this fixed it for me

DrvPath = Mid(Subfolder.Path,Len(SysDrvFldr),StrLenth + 1)

Posted

You don't need to specify the length for the Mid function so the following should work.

DrvPath = Mid(Subfolder.Path,Len(SysDrvFldr))

With this line you can remove the lines for L1, L2, and StrLenth.

length

Number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the start position to the end of the string are returned.

Posted

Thanks all.

I'm working on adding in checks for the INF files, but that's led to a problem in places where multiple INFs exist in a folder. For each INF file it creates another entry in the OEMPnP... section.

So, in my case I have the drivers for the ViewSonic monitors. ViewSonic bundles like 8 INF files into thier package. So, I get 8 "Drivers\Viewsonic" entries.

Mike

Posted

Can I see your current code. You might be able to create a srting variabe called LastFldr and check if the current folder is the same as the last folder.

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...