Real Geek Forums  

Go Back   Real Geek Forums > Archives > Operating Systems > Windows XP > Windows XP WMI

Notices

Reply

Win32_NetworkAdapterConfiguration.IPAddress empty ?

 

LinkBack Thread Tools Display Modes
Old 11-09-2007, 03:48 PM   #1 (permalink)
Default Win32_NetworkAdapterConfiguration.IPAddress empty ?

Hi,

I write script to configure ip address of adapter. In case of multi
adapter , I start to show theses adapter with name and IP to choice wich
one we want to set.
My problem... When I check "Win32_NetworkAdapterConfiguration.IPAddress"
and receive empty value when no cable is connecte. But there is a value
write somewhere because manualy we can see IP address in TCP/IP properties.

If someone has a solution, I will be happy to know it.

Thanks in advance
(sorry for my english ^^)

Arnaud
--------------------------------------------
Code:

On Error Resume Next
'
################################################## ##########################
' Initialisation of variable and object global
Dim objSHELL, objNET, objFSO, objWMIService
Dim objGTextFile, objGIE

Dim strGTempPath, strGFormName


Set objSHELL = WScript.CreateObject("WScript.Shell")
Set objNET = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonat e}!\\.\root\cimv2")


'The iomode argument can have any of the following settings
Const ForReading = 1 'Open a file for reading only. You can't
write to this file.
Const ForWriting = 2 'Open a file for writing.
Const ForAppending = 8 'Open a file and write to the end of the
file.

'The format argument can have any of the following settings
Const TristateUseDefault = -2 'Opens the file using the system
default.
Const TristateTrue = -1 'Opens the file as Unicode.
Const TristateFalse = 0 'Opens the file as ASCII.

' Modification on registry for allow execution of code in IE Windows
objSHELL.RegWrite "HKCU\Software\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_ LOCKDOWN\iexplore.exe",0,"REG_DWORD"
objSHELL.RegWrite "HKLM\Software\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_ LOCKDOWN\iexplore.exe",1,"REG_DWORD"
objSHELL.RegWrite "HKCU\Software\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_ LOCKDOWN\Settings\LOCALMACHINE_CD_UNLOCK",1,"REG_D WORD"

'Show Browser gui for take setting informations
strGTempPath = objShell.ExpandEnvironmentStrings("%Temp%")
strGFormName = "DetectPoolConf.html"
Set objGTextFile = objFSO.OpenTextFile(strGTempPath & "\" &
strGFormName, ForAppending, True)
With objGTextFile
.WriteLine("<HTML>")
.WriteLine("<HEAD>")
.WriteLine("<TITLE>IP reconfiguration</TITLE>")
.WriteLine("</HEAD>")
.WriteLine("<body bgcolor=""#FFFFD2"" scroll=""no"">")
.WriteLine("<form name=""InstForm"">")
.WriteLine("<select size""1"" name=""Location"">")
.WriteLine("<option value=""21"">ID01 subnet21</option>")
.WriteLine("<option value=""22"">ID02 subnet22</option>")
.WriteLine("<option value=""23"">ID03 subnet23</option>")
.WriteLine("<option value=""26"">ID06 subnet26</option>")
.WriteLine("<option value=""28"">ID08 subnet28</option>")
.WriteLine("<option value=""29"">ID09 subnet29</option>")
.WriteLine("<option value=""30"">ID10 subnet30</option>br")
.WriteLine("<option value=""31"">ID11 subnet31</option>br")
.WriteLine("<option value=""32"">ID12 subnet32</option>br")
.WriteLine("<option value=""33"">ID13 subnet33</option>br")
.WriteLine("<option value=""64"">ID14 subnet64</option>br")
.WriteLine("<option value=""35"">ID15 subnet35</option>br")
.WriteLine("<option value=""36"">ID16 subnet36</option>br")
.WriteLine("<option value=""37"">ID17 subnet37</option>br")
.WriteLine("<option value=""38"">ID18 subnet38</option>br")
.WriteLine("<option value=""39"">ID19 subnet39</option>br")
.WriteLine("<option value=""40"">ID20 subnet40</option>br")
.WriteLine("<option value=""41"">ID21 subnet41</option>br")
.WriteLine("<option value=""42"">ID22 subnet42</option>br")
.WriteLine("<option value=""43"">ID23 subnet43</option>br")
.WriteLine("<option value=""44"">ID24 subnet44</option>br")
.WriteLine("<option value=""46"">ID26 subnet46</option>br")
.WriteLine("<option value=""47"">ID27 subnet47</option>br")
.WriteLine("<option value=""48"">ID28 subnet48</option>br")
.WriteLine("<option value=""49"">ID29 subnet49</option>br")
.WriteLine("<option value=""50"">ID30 subnet50</option>br")
.WriteLine("<option value=""51"">ID31 subnet51</option>br")
.WriteLine("<option value=""52"">ID32 subnet52</option>br")
.WriteLine("<option value=""121"">D01 subnet121</option>br")
.WriteLine("<option value=""125"">D05 subnet125</option>br")
.WriteLine("<option value=""134"">D14 subnet134</option>br")
.WriteLine("<option value=""136"">D16 subnet136</option>br")
.WriteLine("<option value=""146"">D26 subnet146</option>br")
.WriteLine("<option value=""148"">D28 subnet148</option>br")
.WriteLine("<option value=""149"">D29 subnet149</option>br")
.WriteLine("</select>")
.WriteLine("<select size""1"" name=""DetNumber"">")
.WriteLine("<option value=""detpca"">detpcAXX (190)</option>")
.WriteLine("<option value=""detpcb"">detpcBXX (191)</option>")
.WriteLine("<option value=""detpcc"">detpcCXX (192)</option>")
.WriteLine("</select>")
.WriteLine("Variable Hostname value : <input type=""text""
size=""20"" name=""variable""><hr>")
.WriteLine("<input type=""button"" name=""Bok"" value=""OK"" >")
.WriteLine("<input type=""button"" name=""Bca"" value=""Cancel"" >")
.WriteLine("</form>")
.WriteLine("<script language=""VBScript"">")
.WriteLine("<!--")
.WriteLine("Dim ready, index")
.WriteLine("Sub Bok_OnClick")
.WriteLine("ready=1")
.WriteLine("End Sub")
.WriteLine("Sub Bca_OnClick")
.WriteLine("ready=-1")
.WriteLine("End Sub")
.WriteLine("Sub Window_OnLoad()")
.WriteLine("ready=0")
.WriteLine("End Sub")
.WriteLine("Public Function CheckVal()")
.WriteLine("CheckVal=ready")
.WriteLine("End function")
.WriteLine("'-->")
.WriteLine("</script>")
.WriteLine("</body>")
.WriteLine("</html>")
End With
objGTextFile.Close

' IE Startup
Set objGIE = CreateObject("InternetExplorer.Application")
With objGIE
.Left = 150
.Top = 100
.Height = 170
.Width = 280
.MenuBar = 0
.ToolBar = 0
.StatusBar = 0
.navigate strGTempPath & "\" & strGFormName
.Visible = 1
End With
' Wait until MSIE is ready and suspend 200ms to lower CPU load
Do While (objGIE.Busy)
WScript.Sleep 200
Loop
' Wait until the user clicks the button
Do
WScript.Sleep 200
Loop While (objGIE.Document.Script.CheckVal() = 0)
' The user closes the form without clicking the Ok or Cancel button
If Err <> 0 Then
Wscript.Echo "Install Process Cancel"
objFSO.DeleteFile strGTempPath & "\" & strGFormName, True
Wscript.quit
End If
test=objGIE.Document.Script.CheckVal()
If test=-1 Then
objIE.Quit
Wscript.Echo "Install Process Cancel"
objFSO.DeleteFile strGTempPath & "\" & strGFormName, True
Wscript.quit
End If
objFSO.DeleteFile strGTempPath & "\" & strGFormName, True

strGHostname = objGIE.Document.InstForm.DetNumber.options.value &
objGIE.Document.InstForm.Location.options.value
Select Case objGIE.Document.InstForm.DetNumber.options.value
Case "detpca"
strGIP = "160.103." &
objGIE.Document.InstForm.Location.options.value & ".190"
Case "detpcb"
strGIP = "160.103." &
objGIE.Document.InstForm.Location.options.value & ".191"
Case "detpcc"
strGIP = "160.103." &
objGIE.Document.InstForm.Location.options.value & ".192"
Case Else
WScript.Quit
End Select
strHostVariable = objGIE.Document.InstForm.variable.value
WScript.Echo strGHostname & VBCRLF & strGIP & VBCRLF & strHostVariable
objGIE.Quit

'
################################################## #############################################
' Starting log windows..
Set objIEGuiWarn = CreateObject("InternetExplorer.Application")
objIEGuiWarn.Navigate "about:blank"
objIEGuiWarn.ToolBar = 0
objIEGuiWarn.StatusBar = 0
objIEGuiWarn.Width = 720
objIEGuiWarn.Height = 400
objIEGuiWarn.Left = 50
objIEGuiWarn.Top = 300
objIEGuiWarn.Visible = 1
objIEGuiWarn.Resizable = true
Do While (objIEGuiWarn.Busy)
Loop
Set objIEDocWarn = objIEGuiWarn.Document
objIEDocWarn.Open
objIEDocWarn.Writeln "<html>"
objIEDocWarn.Writeln "<head><title>Script log</title></head>"
objIEDocWarn.Writeln "<body scroll='yes' bgcolor='crimson'>"
objIEDocWarn.Writeln "<h3><B><Code>Detector Pool reconfiguration script
...</B></h3><br>"
objIEDocWarn.Write ()
objIEDocWarn.Writeln "<table><tr><td colspan=""2""><B>Requested
Settings...<B></td></tr>"
objIEDocWarn.Writeln "<tr><td>Hostname :</td><td>" & strGHostname &
"</td></tr>"
objIEDocWarn.Writeln "<tr><td>IP address :</td><td>" & strGIP & "</td></tr>"
objIEDocWarn.Writeln "<tr><td>Variable :</td><td>" & strHostVariable &
"</td></tr></table>"
objIEDocWarn.Writeln "<table><td colspan=""2""><B>Local PC
informations...<B></td></tr>"
objIEDocWarn.Writeln "<tr><td>Hostname :</td><td>" & objNET.ComputerName
& "</td></tr>"
objIEDocWarn.Writeln "<tr><td>Operating system :</td><td>" &
objSHELL.RegRead("HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\ProductName") & "</td></tr></table>"
objIEDocWarn.Writeln "<table><td colspan=""2""><B>Network adapter
informations......<B></td></tr>"
Set colItems = objWMIService.ExecQuery ("Select * From
Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
objIEDocWarn.Writeln "<tr><td><B>Network adapter number
:<B></td><td><B>" & objItem.Index & "<B></td></tr>"
AdapterInfo(objItem.Index)
objIEDocWarn.Writeln "<tr><td>IP Address;GW :</td><td>"
For Each strIpAddress in objItem.IPAddress
objIEDocWarn.Write strIpAddress & ";"
Next
For Each strDefaultIPGateway in objItem.DefaultIPGateway
objIEDocWarn.Write strDefaultIPGateway & ";"
Next
objIEDocWarn.Write "</td></tr>"
objIEDocWarn.Writeln "<tr><td>DNS Servers :</td><td>"
For Each strDNSServer in objItem.DNSServerSearchOrder
objIEDocWarn.Write strDNSServer & ";"
Next
objIEDocWarn.Write "</td></tr>"
objIEDocWarn.Writeln "<tr><td>WINS Servers :</td><td>" &
objItem.WINSPrimaryServer & ";" & objItem.WINSSecondaryServer & "</td></tr>"
Next

objIEDocWarn.Writeln "</table></body></html>"
'objIEDocWarn.Close

'Set objIEDocWarn = null
'Set objIEGuiWarn = null
'
################################################## #############################################
'
################################################## #############################################
' Sub & Function
'
################################################## #############################################

Sub LogWrite(strLComment)
objIEDocWarn.Writeln strLComment
End Sub

Sub AdapterInfo(intLIndexAdapter)
On Error Resume Next
Set colLItems = objWMIService.ExecQuery("Select * From
Win32_NetworkAdapter Where Index = " & intLIndexAdapter)
For Each objLItem in colLItems
objIEDocWarn.Writeln "<tr><td>Manufacturer :</td><td>"
& objLItem.Manufacturer & "</td></tr>"
objIEDocWarn.Writeln "<tr><td>Adapter Name :</td><td>"
& objLItem.Name & "</td></tr>"
objIEDocWarn.Writeln "<tr><td>MAC Address :</td><td>"
& objLItem.MACAddress & "</td></tr>"
objIEDocWarn.Writeln "<tr><td>Windows Connection
:</td><td>" & objLItem.NetConnectionID & "</td></tr>"
Next
End Sub



Microsoft News
Guest
 
Posts: n/a
Reply With Quote  
Reply

Tags
None

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Win32_NetworkAdapterConfiguration, dynamic dial-up ip, static lan Richard Windows XP WMI 1 02-28-2007 08:54 PM
win32_networkadapterconfiguration problem OM Windows XP WMI 0 05-19-2006 09:51 PM
Cannot empty recycle bin Gail Windows XP Performance & Maintenance 2 12-28-2003 01:51 AM
Recycle bin won't empty Brandon Windows XP Help & Support 0 10-17-2003 06:17 PM
help:summary tab empty Simon B Windows XP Photos 0 10-04-2003 11:36 AM


All times are GMT. The time now is 12:35 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright © 2005 - 2007 RealGeek.com. All rights reserved.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90