Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Mac and IP address from 98 client

Status
Not open for further replies.

slint

Technical User
Jul 2, 2006
48
SE
I have been trying with wmi and it works fine on win2k and xp but i suspect that wmi isent something that you can query in win 98. So how do you get the info from a win 98 machine.


Code:
Set colAdapters = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
     n = 1
 
   For Each objAdapter in colAdapters
    report = report &  "Network adapter info 			" & vbCrLf
    report = report & "******************************************" & vbCrLf
    report = report &  "Network Card 			" & n & vbCrLf
    report = report &  "Description: 			" & objAdapter.Description & vbCrLf
    report = report &  "Physical (MAC) address: 	" & objAdapter.MACAddress & vbCrLf
    report = report &  "Comupter name:			" & objAdapter.DNSHostName & vbCrLf
  
   If Not IsNull(objAdapter.IPAddress) Then
      For i = 0 To UBound(objAdapter.IPAddress)
    report = report &  "IP address:             	" & objAdapter.IPAddress(i) & vbCrLf
      Next
   End If
'40 
   If Not IsNull(objAdapter.IPSubnet) Then
      For i = 0 To UBound(objAdapter.IPSubnet)
    report = report &  "Subnet:                 	" & objAdapter.IPSubnet(i) & vbCrLf
      Next
   End If
 
   If Not IsNull(objAdapter.DefaultIPGateway) Then
      For i = 0 To UBound(objAdapter.DefaultIPGateway)
    report = report &  "Default gateway:        	" & objAdapter.DefaultIPGateway(i) & vbCrLf
      Next
   End If
 
>but i suspect that wmi isent something that you can query in win 98
Suspect without proof? why don't you the query? It won't blow up the m/c. If it fails, install wmi package for win9x.
 
In win9x you must enable WBEM.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I have installed Windows Management Instrumentation (WMI) CORE 1.5 for 9x and can, with the script, get info about installed applications but not any info about ip address or mac addresses. I have used WMI Explorer to see the info from there and all the things i'm looking for is there with the same naming as a win xp machine but still no info gets in to my txt file.

Here is the code that works on 2k and xp
Code:
On Error Resume Next

Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Const HKEY_LOCAL_MACHINE = &H80000002
Const UnInstPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & ".\root\default:StdRegProv")
   
    
report = strComputer & " Computer Inventory" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "OS Information" & vbCrLf & "******************************************" & vbCrLf
For Each objItem in colItems
    report = report &  "Caption: 			" & objItem.Caption & vbCrLf
    report = report &  "Description: 			" & objItem.Description & vbCrLf
    report = report &  "EncryptionLevel: 		" & objItem.EncryptionLevel & vbCrLf
    report = report &  "InstallDate: 			" & objItem.InstallDate & vbCrLf
    report = report &  "Manufacturer: 			" & objItem.Manufacturer & vbCrLf
    report = report &  "MaxNumberOfProcesses: 		" & objItem.MaxNumberOfProcesses & vbCrLf
    report = report &  "Name: 				" & objItem.Name & vbCrLf
    report = report &  "Organization: 			" & objItem.Organization & vbCrLf
    report = report &  "OSProductSuite: 		" & objItem.OSProductSuite & vbCrLf
    report = report &  "RegisteredUser:			" & objItem.RegisteredUser & vbCrLf
    report = report &  "SerialNumber: 			" & objItem.SerialNumber & vbCrLf
    report = report &  "ServicePackMajorVersion:	" & objItem.ServicePackMajorVersion & vbCrLf
    report = report &  "ServicePackMinorVersion: 	" & objItem.ServicePackMinorVersion & vbCrLf
    report = report &  "Version: 			" & objItem.Version & vbCrLf
    report = report &  "WindowsDirectory: 		" & objItem.WindowsDirectory & vbCrLf

Next

	report = report & vbCrLf & "******************************************"  
    report = report & vbCrLf & "Computerhardware info"
    report = report & vbCrLf & "******************************************" & vbCrLf


Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
    report = report &  "Computer serialnr: 		"  & objSMBIOS.SerialNumber & vbCrLf
next


Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colCOMpn = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objCOMpn in colCOMpn
    report = report &  "Computer manufacture: 		"  & objCOMpn.Manufacturer & vbCrLf
    report = report &  "Computer product: 		"  & objCOMpn.Model & vbCrLf
	
	report = report & vbCrLf & "******************************************"  
    report = report & vbCrLf & "User / Network info"
    report = report & vbCrLf & "******************************************" & vbCrLf
    report = report &  "Logged in user: 		"  & objCOMpn.UserName & vbCrLf
    report = report &  "Computername: 			"  & strComputer & vbCrLf
    report = report &  "Domain: 			"  & objCOMpn.Domain & vbCrLf
next


report = report & vbCrLf & "******************************************" & vbCrLf


Set colAdapters = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
     n = 1
 
   For Each objAdapter in colAdapters
    report = report &  "Network adapter info 			" & vbCrLf
    report = report & "******************************************" & vbCrLf
    report = report &  "Network Card 			" & n & vbCrLf
    report = report &  "Description: 			" & objAdapter.Description & vbCrLf
    report = report &  "Physical (MAC) address: 	" & objAdapter.MACAddress & vbCrLf
    report = report &  "Comupter name:			" & objAdapter.DNSHostName & vbCrLf
  
   If Not IsNull(objAdapter.IPAddress) Then
      For i = 0 To UBound(objAdapter.IPAddress)
    report = report &  "IP address:             	" & objAdapter.IPAddress(i) & vbCrLf
      Next
   End If
'40 
   If Not IsNull(objAdapter.IPSubnet) Then
      For i = 0 To UBound(objAdapter.IPSubnet)
    report = report &  "Subnet:                 	" & objAdapter.IPSubnet(i) & vbCrLf
      Next
   End If
 
   If Not IsNull(objAdapter.DefaultIPGateway) Then
      For i = 0 To UBound(objAdapter.DefaultIPGateway)
    report = report &  "Default gateway:        	" & objAdapter.DefaultIPGateway(i) & vbCrLf
      Next
   End If
 
   If Not IsNull(objAdapter.DNSServerSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
    report = report &  "DNS servers:			" & objAdapter.DNSServerSearchOrder(i) & vbCrLf
      Next
   End If
    
    report = report &  "DNS domain: 			" & objAdapter.DNSDomain & vbCrLf

   If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
    report = report &  "DNS suffix search list: " & objAdapter.DNSDomainSuffixSearchOrder(i) & vbCrLf
      Next
   End If
 
	report = report &  "DHCP enabled:        		" & objAdapter.DHCPEnabled & vbCrLf
    report = report &  "DHCP server:         		" & objAdapter.DHCPServer & vbCrLf
						 
			If Not IsNull(objAdapter.DHCPLeaseObtained) Then
		      utcLeaseObtained = objAdapter.DHCPLeaseObtained & vbCrLf
		      strLeaseObtained = WMIDateStringToDate(utcLeaseObtained)
			Else
		      strLeaseObtained = ""
			End If
    report = report &  "DHCP lease obtained: 		" & strLeaseObtained & vbCrLf


		   If Not IsNull(objAdapter.DHCPLeaseExpires) Then
				utcLeaseExpires = objAdapter.DHCPLeaseExpires & vbCrLf
				strLeaseExpires = WMIDateStringToDate(utcLeaseExpires)
			Else
				strLeaseExpires = ""
			End If
    report = report &  "DHCP lease expires:  		" & strLeaseExpires & vbCrLf
    report = report &  "Primary WINS server:   		" & objAdapter.WINSPrimaryServer & vbCrLf
    report = report &  "Secondary WINS server: 		" & objAdapter.WINSSecondaryServer & vbCrLf

						 
   n = n + 1
   'tf.Close
 
Next


Function WMIDateStringToDate(utcDate)
   WMIDateStringToDate = CDate(Mid(utcDate, 5, 2)  & "/" & _
       Mid(utcDate, 7, 2)  & "/" & _
           Left(utcDate, 4)    & " " & _
               Mid (utcDate, 9, 2) & ":" & _
                   Mid(utcDate, 11, 2) & ":" & _
                      Mid(utcDate, 13, 2))
End Function


Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Memory and Processor Information" & vbCrLf & "******************************************" & vbCrLf
For Each objComputer in colSettings 
'report = report & objComputer.Name & vbcrlf
report = report & objComputer.TotalPhysicalMemory /1024\1024+1 & "MB Total memory" & vbcrlf
Next
Set colSettings = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objProcessor in colSettings 
report = report & objProcessor.Description & " Processor" & vbCrLf
Next

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Disk Drive Information" & vbCrLf & "******************************************" & vbCrLf

Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
report = report & objLogicalDisk.FreeSpace /1024\1024+1 & "MB Free Disk Space" & vbCrLf
report = report & objLogicalDisk.Size /1024\1024+1 & "MB Total Disk Space" & vbCrLf

oReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys
software = software & vbCrLf & "******************************************" & vbCrLf
software = software & "Installed Software" & vbCrLf & "******************************************" & vbCrLf
For Each subkey In arrSubKeys
'MsgBox subkey
If Left (subkey, 1) <> "{" Then
    software = software & subkey & vbCrLf
End If
Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile ("C:\Data\SCRIPTS\" & strComputer & ".txt", true)
ts.write report
ts.write software
ts.close
 
i found that the script didnt get the computername right for win 98 machines. So insted of this:
Code:
strComputer = env.Item("Computername")

i used this:

Code:
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top