• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 588
  • Last Modified:

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  
0
mbresit
Asked:
mbresit
1 Solution
 
RobSampsonCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now