dthomson
Posts: 1382
Score: 223 Joined: 6/20/2001 From: Eastern Shore Maryland, USA Status: offline
|
Here you go. I ended up writing some code
On Error Resume Next
' Some constants
' HKLM used for WMI
Const HKEY_LOCAL_MACHINE = &H80000002
' Name of the WinPE WinBom.ini file which is to be created.
Const WinBom_File = " C:\WinBom.ini"
Set objFSO = CreateObject(" Scripting.FileSystemObject" )
Set objWshShell = CreateObject(" Wscript.Shell" )
Set objWMIRegistry = GetObject(" winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv" )
' Load the system registry hive
objWshShell.Run " Reg.exe LOAD HKLM\TempHive C:\Windows\System32\Config\System" , 0, True
' Enum the specified registry key
objWMIRegistry.EnumKey HKEY_LOCAL_MACHINE, " TempHive\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}" , arrSubKeys
' Loop through the returned array and find the network card
For Each subkey In arrSubKeys
strSubKey = " TempHive\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & subkey
intType = Null
' Is this item a nic?
intResult = objWMIRegistry.GetStringValue(HKEY_LOCAL_MACHINE, strSubKey, " BusType" , intType)
If intType = 5 Then
intResult = objWMIRegistry.GetStringValue(HKEY_LOCAL_MACHINE, strSubKey, " NetCfgInstanceId" , strValue)
strSubKey = " TempHive\ControlSet001\Services\Tcpip\Parameters\Interfaces\" & strValue
' Determine if DHCP is in use
intResult = objWMIRegistry.GetDWordValue(HKEY_LOCAL_MACHINE, strSubKey, " EnableDHCP" , intValue)
If intValue = 0 Then
' Static IP Addressing is being used. Let' s get the IP, Subnet Mask, and Gateway
blnDHCP = False
objWMIRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE, strSubKey, " IPAddress" , arrIP
objWMIRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE, strSubKey, " SubnetMask" , arrSubnet
objWMIRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE, strSubKey, " DefaultGateway" , arrGateway
Else
blnDHCP = True
End If
End If
Next
' Unload the system registry hive
objWshShell.Run " Reg.exe UNLOAD HKLM\TempHive" , 0, True
' Create the WinBom.ini file
Set objFile = objFSO.OpenTextFile(WinBom_File, 2, True)
objFile.WriteLine " [Factory]"
objFile.WriteLine " WinBOMType=WinPE"
objFile.WriteLine " Reseal=No"
objFile.WriteLine " [WinPE]"
objFile.WriteLine " Restart=No"
objFile.WriteLine " [PnPDriverUpdate]"
objFile.WriteLine " [PnPDrivers]"
objFile.WriteLine " [NetCards]"
objFile.WriteLine " [UpdateInis]"
objFile.WriteLine " [FactoryRunOnce]"
objFile.WriteLine " [Branding]"
objFile.WriteLine " [AppPreInstall]"
' Add the static IP data?
If NOT blnDHCP Then
objFile.WriteLine " [WinPE.Net]"
objFile.WriteLine " Gateway = " & Join(arrGateway, " ," )
objFile.WriteLine " IPConfig = " & Join(arrIP, " ," )
objFile.WriteLine " StartNet = Yes"
objFile.WriteLine " SubnetMask = " & Join(arrSubnet, " ," )
End If
objFile.Close
Set objFile = Nothing Some details: If you are running WinPE from a cd or iso, then you will need to add a RAM Disk to your WinPE build and update the WinBom_File constant in the script to have the script put the WinBom file on the RAM Disk. This is due to the fact that WinPE booted from iso or cd does NOT have a writable file system. You will need to modify the WinBom.ini file(s) which are in your WinPE build to point to the alternate WinBom.ini file which is specified by the WinBom_File constant and subsequently created by this script. The modified WinBom.ini file will look something like this:
[Factory]
WinBOMType=WinPE
Reseal=No
NewWinbom = C:\winbom.ini
[WinPE]
Restart=No
[PnPDriverUpdate]
[PnPDrivers]
[NetCards]
[UpdateInis]
[FactoryRunOnce]
[Branding]
[AppPreInstall] See the Windows Preinstallation Environment User' s Guide for assistance on modifying the WinBom.ini file. HTH Let me know if you have questions. P.S. I have attached the script to this post.
Attachment (1)
< Message edited by dthomson -- 9/8/2005 11:11:52 PM >
_____________________________
Dan Please rate my post My blog My articles Code Repository
|