Windows XP script to Windows 7

can someone assist with converting the following syntax from a windows XP script to where Windows 7 can run it

Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objWSHNetwork = CreateObject("WScript.Network")
Set objWMI = GetObject("WinMGMTS:root\cimv2")

strWQL = "SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'"

Set colIPResults = objWMI.ExecQuery(strWQL)

For Each objNIC In colIPResults
For Each strIPAddress in objNIC.IPAddress
            If Left(strIPAddress, 2) = 10 Then
                  strAddresses = strIPAddress
            End If
Next
Next

Set objDomain = GetObject("LDAP://rootDSE")
strDC = objDomain.Get("dnsHostName")

For Each objOS in GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")
strOSName = objOS.Caption
strServicePack = objOS.ServicePackMajorVersion  
Next

Dim objNet
Dim strInfo

Set objNet = CreateObject("WScript.NetWork")

strInfo = "User Name = "                   & objNet.UserName & vbCRLF & vbCRLF & _
          "Computer Name = "                   & objNet.ComputerName & vbCRLF & vbCRLF & _
          "IP Address = "                   & strAddresses & vbCRLF & vbCRLF & _
        "Domain Controller = "             & strDC & vbCRLF & vbCRLF & _
        "Operating System = "                   & strOSName & vbCRLF & vbCRLF & _
        "Service Pack Version = "             & strServicePack
MsgBox strInfo
      
Set objNet = Nothing  
mbresitAsked:
Who is Participating?
 
RobSampsonConnect With a Mentor Commented:
Hi, try this.  I think the problem was because of the IPv6 IP addresses.

Regards,

Rob.
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objWSHNetwork = CreateObject("WScript.Network")
Set objWMI = GetObject("WinMGMTS:root\cimv2")

strWQL = "SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'"

Set colIPResults = objWMI.ExecQuery(strWQL)

For Each objNIC In colIPResults
For Each strIPAddress in objNIC.IPAddress
	If InStr(strIPAddress, "::") = 0 Then
		If Left(strIPAddress, 2) = 10 Then
			strAddresses = strIPAddress
		End If
	End If
Next
Next

Set objDomain = GetObject("LDAP://rootDSE")
strDC = objDomain.Get("dnsHostName")

For Each objOS in GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")
strOSName = objOS.Caption 
strServicePack = objOS.ServicePackMajorVersion   
Next

Dim objNet
Dim strInfo

Set objNet = CreateObject("WScript.NetWork")

strInfo = "User Name = "                   & objNet.UserName & vbCRLF & vbCRLF & _
          "Computer Name = "                   & objNet.ComputerName & vbCRLF & vbCRLF & _
          "IP Address = "                   & strAddresses & vbCRLF & vbCRLF & _
        "Domain Controller = "             & strDC & vbCRLF & vbCRLF & _
        "Operating System = "                   & strOSName & vbCRLF & vbCRLF & _
        "Service Pack Version = "             & strServicePack
MsgBox strInfo
      
Set objNet = Nothing

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.