Help - Search - Members - Calendar
Full Version: WinPE 2.0 Question
MSFN Forums > Unattended Windows Discussion & Support > Windows PE

   
Google Internet Forums Unattended CD/DVD Guide
lbhans
Greetings,

I am new to WinPE and I am having some difficulty with the network settings.
I have built the WinPE environment and have created CDs to boot a system and image it to a locally attached USB drive with no problem. My problem is when I try to image over a network connection. When I boot WinPE, it leases an IP address and connects to the network with no problem. However, when I start the image process from Ghost32, the speed is ridiculously slow. i am pretty sure that it is because the NIC is set to auto detect the speed and duplex whereas the swith is hard set to 100/Full. In our environment, this combination does not work. I need to find a way to force the NIC to 100/Full from withing the WinPE environment. Here is what I have tried already:

1. Downloaded a utility called PENETCFG from a website called "The Truth" It work in an XP environment, but not on WinPE since version 2.0 uses a Vista Kernel. At the uggestion of "The Truth", I copied the TCPIPREG.SYS file to the WinPE image and imported the appropriate registry keys to make it work, but still nothing.

Is there any other way to configure the NIC settings from within PE?

Is there a way to build a PE Image using the XP OS?

Any help would be mot appreciated

L
Tripredacus
The PE will use whatever network speed that the Vista drivers you injected into the WinPE is set for. You should know other things that will force slower network traffic. Also, make sure your NIC on the server is set for the speed you want, or if you are using 2008, check the WDS speed setting. I think the default setting is 100Mbps.
lbhans
I think I know why PENETCFG does not work. When I apply the registry settings to the Booted WinPE iamge, they do not activate and require a reboot, which of course brings the machine back up without the TCPIPREG.Sys working. I need to incorporate those Registry settings in the PE image before I commit it so they will become active as WinPE boots off of the CD. However, the instructions for making the registry changes do not seem to apply since the command lines do not work. I am going to build a separet environment and attempt to make the premanent registry changes before the image is prepped.

Tripredacus
I believe in order to make registry changes to the PE, you need to mount the image, then mount the offline registry hive and make changes that way. I haven't actually tried this yet but it is the only thing I can think of.
Jazkal
yes, you would need to mount the reg hive before you finish the winpe wim image.
lbhans
Yep, I did load the System and Software hives and made the changed prior tp prepping the image and committing it. Still no go. I am getting ready to go with BartPE. It has the networkig configurator built in and the documentation is much more intuitive and comprehensive.
TheReasonIFail
I think I may have a VB script that will set your NIC to 100/Full.

Let me see if I can dig it up...
TheReasonIFail
CODE
On Error Resume    Next

'---- ParameterDirectionEnum Values ----
Const adParamInput = &H0001
rem Const adParamOutput = &H0002

'---- CommandTypeEnum Values ----
Const adCmdStoredProc = &H0004

rem 3 tasks
rem 1. Store in Database - In Progress
rem 2. If 100 Full, say 100/ Full - Done
rem 3. If not, say Not Set - Done
rem 4. Fix it - Done
rem 6. Stop & Start the service to make it up-to-date - In Progress

Set    StdOut = WScript.StdOut

const HKEY_LOCAL_MACHINE = &H80000002

const IDEAL_SPEED = "100"
const IDEAL_DUPLEX = "FULL"

Class NICInfo
    Dim MACAddress
    Dim Name
    Dim IPAddress
    Dim MachineName
    Dim Result
    Dim Notes
End Class

Dim oNICInfo
Set oNICInfo = new NICInfo

Dim    strKeyCurrentPath
strKeyCurrentPath =    "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}"
Dim    strCurrentControlNetwork
strCurrentControlNetwork = "SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002bE10318}"
Dim    strCurrentVersion
strCurrentVersion =    "Software\Microsoft\Windows    NT\CurrentVersion"

Dim oArrayPropertyType
rem if there are two properties, first property is for 100/10 & second property is for Full/Half
oArrayPropertyType = Array("ConnectionType", "", _
                            "Duplex", "MediaSpeed", _
                            "media", "", _
                            "Media_type", "", _
                            "MediaSelect", "Duplexmode", _
                            "MediaSpeed", "", _
                            "NetworkMedia", "", _
                            "RequestedMediaType", "", _
                            "SpeedDuplex", "" )
Dim    oReg
Dim    oSvc

Dim    WshSHell
set    WshShell = CreateObject("WScript.Shell")

Dim    strComputer    
'set strComputer = "."
Set oDictionary = CreateObject("Scripting.Dictionary")

Dim bShowUsage
bShowUsage = True

Dim    oArgs
'If RetrieveArguments() = bShowUsage Then
    'Call ShowUsage
'Else
    Call setnicInfo
'End    If

rem    Get    the    NIC    Info
Sub    setnicInfo
    
    StdOut.Write    vbNewLine &    _
                    "----------------------------------------------------------"  & vbNewLine &    _
                    "Computer Name" & vbTab & "Result" & vbTab & "Details" & vbNewLine & _
                    "----------------------------------------------------------"  & vbNewLine & _
                    vbNewLine

    'for    each oComputer in    oDictionary

        strComputer = "." ' oDictionary.Item(oComputer)
        err.Clear
        rem    Get    WMI    object for registry
        'Set    oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"    & strComputer &    "\root\default:StdRegProv")
        On Error Resume    Next
        
        Set    oReg = GetObject("winmgmts:\\"    & strComputer &    "\root\default:StdRegProv")
        If Err.Number <> 0 Then
            StdOut.WriteLine "Error: (Unavailable Registry at "    & strComputer &    ") " & Err.Description
            Else If    (GetOSVersion()    < 5) Then
                StdOut.WriteLine "Error: (Computer at "    & strComputer &    ") Version Less than 5"
                Else
                rem    Get    WMI    object for registry
                On Error Resume    Next
                Set    oSvc = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
                If Err.Number <> 0 Then
                    StdOut.WriteLine "Error:  " & Err.Description
                Else
                    Dim    oArrayPNPDeviceID
                    rem    for    each oInstNWAC in oSvc.execquery("select * from    win32_networkadapterConfiguration where    IPEnabled =    'True'")
                        for    each oInstNWA in oSvc.execquery("select    * from win32_networkadapter    where MACAddress <>    null")
                        rem    where MACAddress = " & Str(oInstNWAC.MACAddress) & "")
                            If (oInstNWA.PNPDeviceID <>    empty) Then
                                oArrayPNPDeviceID =    Split(oInstNWA.PNPDeviceID,    "\", -1, 1)
                                If (oArrayPNPDeviceID(0) <>    "ROOT")    Then
                                    For    each oInstNWAC in oSvc.execquery("select * from    win32_networkadapterConfiguration where    IPEnabled =    'True'")
                                        If (oInstNWAC.Caption =    oInstNWA.Caption) Then
                                            rem    Get    the    Caption    for    the    Network    Adapter
                                            strCaption = GetRealCaptionStr(oInstNWAC.Caption)
                                            
                                            rem    Continue, only if Connection is    Open
                                            rem    Dim    sPnpInstanceIDValue
                                            rem    sPnpInstanceIDValue    = empty
                                            rem    oReg.GetStringValue    HKEY_LOCAL_MACHINE,    strCurrentControlNetwork & "\" & oInstNWAC.SettingID & "\Connection", "PnpInstanceID", sPnpInstanceIDValue
                                            
                                            Dim    sNetworkName
                                            sNetworkName = empty
                                            oReg.GetStringValue    HKEY_LOCAL_MACHINE,    strCurrentControlNetwork & "\" & oInstNWAC.SettingID & "\Connection", "Name", sNetworkName
                                            
                                            rem    Continue, if there is no error & PnpInstanceID is non-empty
                                            If (err.number = 0)    Then
                                                rem Dim strPropertyDesc
                                                rem strPropertyDesc    = ""
                                                
                                                rem strPropertyDesc    =    
                                                
                                                rem    Print the computer name
                                                StdOut.Write strComputer & vbTab
                                                oNICInfo.MachineName = oInstNWA.SystemName
                                                
                                                rem    Get the NIC Name
                                                oNICInfo.Name = oInstNWA.Caption
                                                
                                                stop
                                                rem    Print the MAC Address for the Network Adapter
                                                rem StdOut.Write oInstNWA.MACAddress & vbTab
                                                oNICInfo.MACAddress = oInstNWA.MACAddress
                                                oNICInfo.IPAddress = oInstNWAC.IPAddress(0)
    
                                                GetAllPropertiesDesc(GetLast4Digit(oInstNWA.Caption))
                                                rem StdOut.Write " (" &    strPropertyDesc    & ")" &    vbTab
                                                
                                                If (True = bStoringToDB) Then
                                                    StoreToDatabase

                                                    If (0 <> err.number) Then
                                                        StdOut.WriteLine "Cant Save to Database. Error: " & Err.Description
                                                    End If
                                                End If
                                                
                                                StdOut.WriteLine
                                            End    If
                                        End    If
                                    Next
                                End    If
                            End    If
                        next
                End    If
            End    If
        End    If
    'next
End    Sub
rem End If

rem    Get    last 4 digits from Caption String
Function GetLast4Digit(oString)
    rem    split the sting    with ]
    Dim    oArray
    oArray = Split(oString,    "]", -1, 1)

    rem    get    the    last 4 digits from Caption
    GetLast4Digit =    Right(oArray(0), 4)
End    Function

rem    Get    Real Caption String    from a String received from    Registry Value
Function GetRealCaptionStr(oString)
    rem    split the sting    with ]
    Dim    oArray
    oArray = Split(oString,    "]", -1, 1)

    rem    remove the first space too
    GetRealCaptionStr =    LTrim(oArray(1))
End    Function

rem Get the Properties Description & if found, keep the Index
Function GetAllPropertiesDesc(str4Digits)
    Dim Result
    Result = "FAIL2"
    Dim    strPropertyDesc
    strPropertyDesc    = ""
    Dim ArrayCount
    'Get the Array Count of the Properties
    stop
    ArrayCount = UBound(oArrayPropertyType, 1) - LBound(oArrayPropertyType, 1)
    'Go through all the Property Array Elements
    For iCounter = 0 to ArrayCount step 2
        strPropertyDesc = GetPropertyDesc(str4Digits, oArrayPropertyType(iCounter))
        
        If (strPropertyDesc <> "") Then
            If (oArrayPropertyType(iCounter+1) <> "")Then
                strPropertyDesc    = strPropertyDesc & "***" & GetPropertyDesc(str4Digits, oArrayPropertyType(iCounter+1))
            End If
            Exit For
        End If
    Next
    If (strPropertyDesc <> "") Then
        rem    if strPropertyType1ValuDesc    contains 100 & Full    string,    the    result is PASS,    otherwise its FAIL
        If ((InStr(1, strPropertyDesc, IDEAL_SPEED, 0)>0)    and    (InStr(1, UCase(strPropertyDesc), IDEAL_DUPLEX, 0)>0) ) Then
            StdOut.Write "100/FULL"
            oNICInfo.Result = "PASS"
            oNICInfo.Notes = "Speed/Duplex is alreay set to 100FULL"
        Else
            StdOut.Write "Not 100 Full"
            oNICInfo.Result = "FAIL"
            oNICInfo.Notes = "Speed/Duplex is NOT set to 100FULL"
            rem Fix It
            SetPropertyDesc str4Digits, iCounter
        End    If
    Else
        StdOut.Write "ERROR"
        oNICInfo.Result = "FAIL"
        oNICInfo.Notes = "Couldnt Find the Registery Value for NIC Properties"
    End If
End    Function

Function GetPropertyDesc(str4Digits, strPropertyType)
    Dim    strPropertyDesc
    strPropertyDesc    = ""
    
    rem    get    the    registry value for the specific    type of    adapter
    oReg.GetStringValue    HKEY_LOCAL_MACHINE,    strKeyCurrentPath &    "\"    & str4Digits, strPropertyType, strTempValue
    rem    get    the    real string    value for the registry value
    oReg.GetStringValue    HKEY_LOCAL_MACHINE,    strKeyCurrentPath &    "\"    & str4Digits & "\Ndi\params\" &    strPropertyType    & "\enum", strTempValue, strPropertyDesc

    GetPropertyDesc    = strPropertyDesc
End    Function

Sub SetPropertyDesc(str4Digits, iCoutner)
    rem    get    the    real string    value for the registry value
    oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyCurrentPath & "\" & str4Digits & "\Ndi\params\" & oArrayPropertyType(iCoutner) & "\enum", arrValueNames1, arrValueTypes1
    
    rem Clear all the previous errors
    Err.Clear
    rem Go through all the sub keys
    For i=0 To UBound(arrValueNames1)
        If ("" = oArrayPropertyType(iCoutner+1)) Then
            oReg.GetStringValue    HKEY_LOCAL_MACHINE, strKeyCurrentPath & "\" & str4Digits & "\Ndi\params\" & oArrayPropertyType(iCoutner) & "\enum", arrValueNames1(i), arrValue
            If ((InStr(1, arrValue, IDEAL_SPEED, 0)>0) and (InStr(1, UCase(arrValue), IDEAL_DUPLEX, 0)>0)) Then
                oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyCurrentPath & "\" & str4Digits, oArrayPropertyType(iCoutner), arrValueNames1(i)
                rem if any eror print & exit
                If Err.Number <> 0 Then
                    StdOut.WriteLine "FAIL2: Couldnt Fix it for Value of " & oArrayPropertyType(iCoutner) & "Error:" & Err.Description
                    oNICInfo.Result = "FAIL"
                    oNICInfo.Notes = "Can NOT fix Speed/Duplex=100FULL; Error:" & Err.Description
                Else
                    StdOut.WriteLine "PASS2"
                    oNICInfo.Result = "PASS"
                    oNICInfo.Notes = "Fixed Speed/Duplex=100FULL"
                End If
                Exit For
            End If
        Else
            oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyCurrentPath & "\" & str4Digits & "\Ndi\params\" & oArrayPropertyType(iCoutner+1) & "\enum", arrValueNames2, arrValueTypes2
    
            rem Go through all the sub keys
            For j=0 To UBound(arrValueNames2)
                oReg.GetStringValue    HKEY_LOCAL_MACHINE, strKeyCurrentPath & "\" & str4Digits & "\Ndi\params\" & oArrayPropertyType(iCoutner) & "\enum", arrValueNames2(j), arrValue
                If (InStr(1, UCase(arrValue), IDEAL_DUPLEX, 0)>0) Then
                    oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyCurrentPath & "\" & str4Digits, oArrayPropertyType(iCoutner), arrValueNames2(j)
                    rem if any eror print & exit
                    If Err.Number <> 0 Then
                        StdOut.WriteLine "FAIL2: Couldnt Enter Value of " & oArrayPropertyType(iCoutner+1) & Err.Description
                        oNICInfo.Result = 0
                        oNICInfo.Notes = "Can NOT fix Speed/Duplex=100FULL; Error:" & Err.Description
                    Else
                        StdOut.WriteLine "PASS2: Could Fix it"
                        oNICInfo.Result = 1
                        oNICInfo.Notes = "Fixed Speed/Duplex=100FULL"
                    End If
                    Exit For
                End if
            Next
        End If
    Next
    
    rem    get    the    registry value for the specific    type of    adapter
    rem oReg.GetStringValue    HKEY_LOCAL_MACHINE,    strKeyCurrentPath &    "\"    & str4Digits, strPropertyType, strTempValue
End    Sub

Function GetOSVersion()
    rem    Get    OS Version from    the    Current    Version    Registry Key
    oReg.GetStringValue    HKEY_LOCAL_MACHINE,    strCurrentVersion, "CurrentVersion", strTempValue
    GetOSVersion = strTempValue
End    Function

Sub    ShowUsage

    StdOut.WriteLine "---------------------------"
    StdOut.Write    "setnic.vbs    - Sets the NIC's Speed & Duplex to 100 FULL & displays WINS Name, Result, Details"    & vbNewLine
                    
    StdOut.WriteLine "---------------------------"
    StdOut.Write    vbNewLine &    _
                    "Help Information: " & vbNewLine & _
                    "Set NIC's Speed & Duplex to 100 FULL & displays WINS Name, Result, Details(PASS1, if no need to change, FAIL1PASS2 if could fix it, FAIL1FAIL2 if couldnt fix it)"    & vbNewLine    & _
                    "setnic.vbs    -m/-Machine WINSName1 [WINSName2] [WINSName3] [...]" & vbNewLine & _
                    "or setnic.vbs    -m . for the localmachine" & vbNewLine & _
                    vbNewLine &    _
                    "Parameters:" &    vbNewLine &    _
                    "WINSName1,2,...Use    Machine    Name(WINS Name)    as the argument    to get NIC info. " &    vbNewLine &    _
                    vbNewLine &    _
                    "WINSFileName Use .dat FileName    as the argument    to get NIC info. " &    vbNewLine &    _
                    vbNewLine &    _
                    "Example:" & vbNewLine & _
                    "setnic.vbs    -m Computername1 Computername2"    & vbNewLine    & _
                    "or setnic.vbs -m . "    & vbNewLine    & _
                    "or setnic.vbs -h"    & vbNewLine    & _
                    vbNewLine &    _
                    "Error:" & vbNewLine & _
                    "If the    computer doesnt    exist or user running the script doesnt    have permission    to access, it will print an    error" & vbNewLine

    StdOut.WriteLine "---------------------------"
End    Sub

Function RetrieveArguments()
    Set oArgs = WScript.Arguments
    ArgsCount = oArgs.Count
    
    Dim    iCounter
    iCounter = 0
    
    bGotFile = False
    bGotMachine = False
    oComputerCount = 0
    
    rem    Get    all    the    Arguments in the Computer Name Array
    While (iCounter    < ArgsCount)
        LowerArg = LCase(oArgs(iCounter))
        Select Case LowerArg
            Case    "/?", _
                    "/help", _
                    "/h", _
                    "-h", _
                    "--help"
                        RetrieveArguments = True
                        Exit Function
            'Case    "-Machine", _
            '        "-m"
            '            If    (bGotFile = True) or (bGotMachine = True) Then
            '                RetrieveArguments = True
            '                Exit Function
            '            End If
                        
                        'bGotMachine = True
            Case Else
                        If (bGotMachine = True) Then
                            oDictionary.Add oComputerCount, oArgs(iCounter)
                            oComputerCount = oComputerCount + 1
                            set strComputer = "."
                        Else
                            RetrieveArguments = True
                            Exit Function
                        End If
        End Select
        iCounter = iCounter + 1
    WEnd
End Function
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.