Prev: use ConnectObject without WScript?
Next: Runas
From: Deephazz on 4 Jan 2006 08:52 Hello, Does anyone know how to get mac adress with vbs. after several attempts, I've been unable to get it from registry.(It does not appear in clear text) Or does anybody know how to get a unique identifier that does not change after formatting and reinstalling the OS ? I'm trying to get the Pc serial number with this code : ========================================================== Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSMBIOS = oWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") For Each oSMBIOS in colSMBIOS strSerial = osmbios.SerialNumber Next ========================================================== But I've not been able to test it so far and therefore I do not know if the pc serial is always the same no matter the number of times the pc has been formatted. Regards.
From: JHP on 4 Jan 2006 09:25 Use this site: http://www.activexperts.com/activmonitor/windowsmanagement/wmi/samples/ WMI Samples Computer Hardware Samples Win32_NetworkAdapterConfiguration "Deephazz" <Deephazz(a)discussions.microsoft.com> wrote in message news:D7BEE2D0-F03F-40EF-9C6C-AE91292EE952(a)microsoft.com... > Hello, > > Does anyone know how to get mac adress with vbs. > after several attempts, I've been unable to get it from registry.(It does > not appear in clear text) > > Or does anybody know how to get a unique identifier that does not change > after formatting and reinstalling the OS ? I'm trying to get the Pc serial > number with this code : > > ========================================================== > Set oWMIService = GetObject("winmgmts:" & > "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > Set colSMBIOS = oWMIService.ExecQuery ("Select * from > Win32_SystemEnclosure") > > For Each oSMBIOS in colSMBIOS > strSerial = osmbios.SerialNumber > Next > ========================================================== > But I've not been able to test it so far and therefore I do not know if > the > pc serial is always the same no matter the number of times the pc has been > formatted. > > Regards.
From: Roger on 4 Jan 2006 09:41 If the serial number is listed in BIOS then this would not change after an OS reload. Otherwise, if you want to find the MAC address, you will first need to identify the active network interface and get the MAC address from it. You'll want to use the Win32_NetworkAdapterConfiguration WMI Class to figure out which adapter is getting an IP from DHCP and use the MAC address from that. Hope this helps. Roger ********Beginning of Code****************** On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 arrComputers = Array("A31559") For Each strComputer In arrComputers WScript.Echo WScript.Echo "==========================================" WScript.Echo "Computer: " & strComputer WScript.Echo "==========================================" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",") WScript.Echo "DefaultIPGateway: " & strDefaultIPGateway WScript.Echo "DHCPEnabled: " & objItem.DHCPEnabled WScript.Echo "DNSDomain: " & objItem.DNSDomain WScript.Echo "DNSHostName: " & objItem.DNSHostName strIPAddress = Join(objItem.IPAddress, ",") WScript.Echo "IPAddress: " & strIPAddress strIPSubnet = Join(objItem.IPSubnet, ",") WScript.Echo "IPSubnet: " & strIPSubnet WScript.Echo "MACAddress: " & objItem.MACAddress WScript.Echo Next Next Function WMIDateStringToDate(dtmDate) WScript.Echo dtm: WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _ & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2)) End Function *******END********** "Deephazz" <Deephazz(a)discussions.microsoft.com> wrote in message news:D7BEE2D0-F03F-40EF-9C6C-AE91292EE952(a)microsoft.com... > Hello, > > Does anyone know how to get mac adress with vbs. > after several attempts, I've been unable to get it from registry.(It does > not appear in clear text) > > Or does anybody know how to get a unique identifier that does not change > after formatting and reinstalling the OS ? I'm trying to get the Pc serial > number with this code : > > ========================================================== > Set oWMIService = GetObject("winmgmts:" & > "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > Set colSMBIOS = oWMIService.ExecQuery ("Select * from > Win32_SystemEnclosure") > > For Each oSMBIOS in colSMBIOS > strSerial = osmbios.SerialNumber > Next > ========================================================== > But I've not been able to test it so far and therefore I do not know if > the > pc serial is always the same no matter the number of times the pc has been > formatted. > > Regards.
From: Dumb Luck on 4 Jan 2006 11:15 So is there a way to get the serial numbers from remote computers?
From: JHP on 4 Jan 2006 12:48
This may help: http://www.microsoft.com/technet/scriptcenter/scripts/hardware/basic/default.mspx "Dumb Luck" <trevor.christiansen(a)gmail.com> wrote in message news:1136391310.025402.265850(a)g47g2000cwa.googlegroups.com... > So is there a way to get the serial numbers from remote computers? > |