mmarable Posted November 28, 2005 Posted November 28, 2005 (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.ThanksMikeConst ForAppending = 8Set FSO = CreateObject("Scripting.FileSystemObject")Set objFile = FSO.GetFile("Drivers Path.vbs")RootFldr = FSO.GetParentFolderName(objFile) 'WScript.Echo RootFldrSysDrvFldr = RootFldr & "\$OEM$\$1\"'WScript.Echo SysDrvFldrDrvrFldr = SysDrvFldr & "Drivers"'WScript.Echo DrvrFldrL1 = Len(SysDrvFldr)Set objTextFile = FSO.CreateTextFile(RootFldr & "\Drivers Path.txt")objTextFile.CloseSet 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 NextEnd SubobjTextFile.Write Chr(34)objTextFile.ClosePS - I've modified the code to fix the typos found. Edited November 29, 2005 by mmarable
Bezalel Posted November 28, 2005 Posted November 28, 2005 I have 2 suggestions for this script;check for the existance if .inf files before adding a directory to the filereplace the 68 in the following line with a variable determined earlier in the scriptDrvPath = Mid(Subfolder.Path,68,StrLenth)
mmarable Posted November 28, 2005 Author Posted November 28, 2005 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
jbm Posted November 28, 2005 Posted November 28, 2005 When I run the script I getOemPnPDriversPath=";;;;;;;;;;;;nXP;;;;;;;;;;;;;XP;XP\DATA;;;;;;;;;;;;;;;;;"
Bezalel Posted November 29, 2005 Posted November 29, 2005 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.
jbm Posted November 29, 2005 Posted November 29, 2005 @BezalelThanks this fixed it for meDrvPath = Mid(Subfolder.Path,Len(SysDrvFldr),StrLenth + 1)
Bezalel Posted November 29, 2005 Posted November 29, 2005 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.
BlueMe Posted November 29, 2005 Posted November 29, 2005 Thank you So much mmarable for this good script !
mmarable Posted November 29, 2005 Author Posted November 29, 2005 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
Bezalel Posted November 29, 2005 Posted November 29, 2005 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now