Macro numero serial del pc
Este dato lo puedo averiguar escribiendo el siguiente comando en ejecutar de windows: wmic bios get serialnumber, mi pregunta es saber cómo lo puedo hacer con una macro en excel, que me ponga este numero en una celda determinada.
Respuesta de James Bond
1
1
James Bond, Si de mis mayores gustos, mis disgustos han nacido, gustos al...
Prueba con este conjunto de macros, no son mías hace tiempo las baje de internet en mi maquina quizá sea porque le cambie la tarjeta madre no se sale el serial de la maquina, eso si te da un buen de información sobre el equipo en el que lo utilices, desde información del Bios hasta información del procesador, monitor etc.
Sub GetBiosInfo() Dim WmObj As Object, test As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Set colitems = WmObj.ExecQuery("Select * from Win32_BIOS") Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "BIOSInfo" Set objsheet = Worksheets("BIOSInfo") Const NumHeader2 = 14 Dim Headers2(NumHeader2) As String Headers2(1) = "Build Number" Headers2(2) = "Current Language" Headers2(3) = "Installable Languages" Headers2(4) = "Manufacturer" Headers2(5) = "Name" Headers2(6) = "Primary BIOS" Headers2(7) = "Release Date" Headers2(8) = "Serial Number" Headers2(9) = "SMBIOS Version" Headers2(10) = "SMBIOS Major Version" Headers2(11) = "SMBIOS Minor Version" Headers2(12) = "SMBIOS Present" Headers2(13) = "Status" Headers2(14) = "Version" For h = 1 To NumHeader2 objsheet.Cells(1, h) = Headers2(h) objsheet.Cells(1, h).Font.Bold = True Next l = 2 For Each objItem In colitems objsheet.Cells(l, 1) = objItem.BuildNumber objsheet.Cells(l, 2) = objItem.CurrentLanguage objsheet.Cells(l, 3) = objItem.InstallableLanguages objsheet.Cells(l, 4) = objItem.Manufacturer objsheet.Cells(l, 5) = objItem.Name objsheet.Cells(l, 6) = objItem.PrimaryBIOS objsheet.Cells(l, 7) = objItem.ReleaseDate serie = objItem.SerialNumber objsheet.Cells(l, 8) = objItem.SerialNumber objsheet.Cells(l, 9) = objItem.SMBIOSBIOSVersion objsheet.Cells(l, 10) = objItem.SMBIOSMajorVersion objsheet.Cells(l, 11) = objItem.SMBIOSMinorVersion objsheet.Cells(l, 12) = objItem.SMBIOSPresent objsheet.Cells(l, 13) = objItem.Status objsheet.Cells(l, 14) = objItem.Version l = l + 1 Next ActiveSheet.UsedRange.Columns.EntireColumn.AutoFit End Sub Sub GetProcessorInfo() Dim WmObj As Object, test As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Set colitems = WmObj.ExecQuery("Select * from Win32_Processor") Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "ProcessorInfo" Set objsheet = Worksheets("ProcessorInfo") Const NumHeader2 = 2 Dim Headers2(NumHeader2) As String Headers2(1) = "System Type" Headers2(2) = "Processor" For h = 1 To NumHeader2 objsheet.Cells(1, h) = Headers2(h) objsheet.Cells(1, h).Font.Bold = True Next l = 2 For Each objItem In colitems objsheet.Cells(l, 1) = objItem.architecture objsheet.Cells(l, 1) = objItem.Description l = l + 1 Next ActiveSheet.UsedRange.Columns.EntireColumn.AutoFit End Sub Sub GetMonitorInfo() Dim WmObj As Object, test As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Set colitems = WmObj.ExecQuery("Select * from Win32_DesktopMonitor") Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "MonitorInfo" Set objsheet = Worksheets("MonitorInfo") Const NumHeader2 = 8 Dim Headers2(NumHeader2) As String Headers2(1) = "Current Monitor Make" Headers2(2) = "Current Monitor Type" Headers2(3) = "Current Monitor Name" Headers2(4) = "Current Monitor Width" Headers2(5) = "Current Monitor Height" Headers2(6) = "Display Type" Headers2(7) = "Pixels Per X Logical Inch" Headers2(8) = "Pixels Per Y Logical Inch" For h = 1 To NumHeader2 objsheet.Cells(1, h) = Headers2(h) objsheet.Cells(1, h).Font.Bold = True Next l = 2 For Each objItem In colitems objsheet.Cells(l, 1) = objItem.MonitorManufacturer objsheet.Cells(l, 2) = objItem.MonitorType objsheet.Cells(l, 3) = objItem.Name objsheet.Cells(l, 4) = objItem.ScreenWidth objsheet.Cells(l, 5) = objItem.ScreenHeight objsheet.Cells(l, 6) = objItem.DisplayType objsheet.Cells(l, 7) = objItem.PixelsPerXLogicalInch objsheet.Cells(l, 8) = objItem.PixelsPerYLogicalInch l = l + 1 Next ActiveSheet.UsedRange.Columns.EntireColumn.AutoFit End Sub Sub GetMemoryInfo() Dim WmObj As Object, test As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "MemoryInfo" Set objsheet = Worksheets("MemoryInfo") Set colitems = WmObj.ExecQuery("Select * from Win32_PhysicalMemory", , 48) Const NumHeader2 = 15 Dim Headers2(NumHeader2) As String Headers2(1) = "Bank Label" Headers2(2) = "Capacity" Headers2(3) = "Data Width" Headers2(4) = "Description" Headers2(5) = "Device Locator" Headers2(6) = "Form Factor" Headers2(7) = "Hot Swappable" Headers2(8) = "Manufacturer" Headers2(9) = "Memory Type" Headers2(10) = "Name" Headers2(11) = "Part Number" Headers2(12) = "Position In Row" Headers2(13) = "Speed" Headers2(14) = "Tag" Headers2(15) = "Type Detail" For h = 1 To NumHeader2 objsheet.Cells(1, h) = Headers2(h) objsheet.Cells(1, h).Font.Bold = True Next l = 2 For Each objItem In colitems objsheet.Cells(l, 1) = objItem.BankLabel objsheet.Cells(l, 2) = objItem.Capacity objsheet.Cells(l, 3) = objItem.DataWidth objsheet.Cells(l, 4) = objItem.Description objsheet.Cells(l, 5) = objItem.DeviceLocator objsheet.Cells(l, 6) = objItem.FormFactor objsheet.Cells(l, 7) = objItem.HotSwappable objsheet.Cells(l, 8) = objItem.Manufacturer objsheet.Cells(l, 9) = objItem.MemoryType objsheet.Cells(l, 10) = objItem.Name objsheet.Cells(l, 11) = objItem.partnumber objsheet.Cells(l, 12) = objItem.PositionInRow objsheet.Cells(l, 13) = objItem.speed objsheet.Cells(l, 14) = objItem.Tag objsheet.Cells(l, 15) = objItem.TypeDetail l = l + 1 Next ActiveSheet.UsedRange.Columns.EntireColumn.AutoFit End Sub Sub Win32_GetDefPrinterExample() Dim WmObj As Object, test As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer") For Each objprinter In colInstalledPrinters mstring = "Current Def Printer :- " _ & "Current Printer Name :- " & objprinter.Name & vbCrLf _ & "-----------------------------------------" MsgBox mstring Next End Sub Sub GetIpMac() Dim WmObj As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Set colitems = WmObj.ExecQuery("Select * from Win32_ComputerSystem", , 48) For Each objItem In colitems strComputerName = objItem.Name Next Set colitems = WmObj.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objItem In colitems n = ("Network Adapter Name: " & objItem.Caption & vbCrLf) For Each objAddress In objItem.IPAddress i = ("IP Address: " & objAddress & vbCrLf) Next m = ("Current MAC Address :- " & objItem.MACAddress & vbCrLf) Next End Sub Function GetIp() As String Dim WmObj As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Set colitems = WmObj.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objItem In colitems GetIp = objItem.IPAddress Next End Function Function GetMac() As String Dim WmObj As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Set colitems = WmObj.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objItem In colitems GetMac = objItem.MACAddress Next End Function Function GetMachineName() As String Dim WmObj As Object On Error Resume Next Set WmObj = GetObject("WinMgmts:{impersonationLevel=impersonate}") Set colitems = WmObj.ExecQuery("Select * from Win32_ComputerSystem", , 48) For Each objItem In colitems GetMachineName = objItem.Name Next End Function
- Compartir respuesta
- Anónimo
ahora mismo
1 respuesta más de otro experto
Respuesta de Abraham Valencia
0
0
Abraham Valencia, Me gusta Excel
[Hola
La instrucción que mencionas lo que te da es el número de serie de la BIOS; para tener ese mismo número en una celda prueba así:
Sub SerialBIOS() Dim List As Object Dim Mibios$ Dim Objeto As Object Set List = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_BIOS") For Each Objeto In List Mibios = "Número de serie de la BIOS: " & Objeto.SerialNumber Next Range("A1") = Mibios End Sub
Comentas
Abraham Valencia
- Compartir respuesta
- Anónimo
ahora mismo