elwood2083
New Member
- Joined
- Nov 7, 2014
- Messages
- 2
<br>
Halito!<br>
<br>
I am attempting to find a code that will grab the serial number of the pc and insert into cell A1. I have found the below code and it works, but it requires you to enter the name of the computer you need serial from, then displays serial in message box. I just want it to grab the serial of the machine its run on and paste to cell A1<br>
<br>
This code does work by the way and is accurate (BY THE WAY, IM NEW AT THIS, IAM SURE YOU CAN TELL)<br>
<br>
On Error Resume Next<br>
<br>
Dim System<br>
<br>
If Wscript.Arguments.Count > 0 Then<br>
sSystem = Wscript.Arguments(0)<br>
<br>
End If<br>
<br>
ComputerName = InputBox("Enter the name of the computer you wish to query")<br>
<br>
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//" & ComputerName & ""<br>
<br>
Set SNSet = GetObject(winmgmt1).InstancesOf("Win32_BIOS")<br>
<br>
For Each SN In SNSet<br>
<br>
MsgBox "The serial number for the specified computer is: " & SN.SerialNumber<br>
<br>
Next<br>
<br>
End Sub<br>
<br><br type="_moz">
Halito!<br>
<br>
I am attempting to find a code that will grab the serial number of the pc and insert into cell A1. I have found the below code and it works, but it requires you to enter the name of the computer you need serial from, then displays serial in message box. I just want it to grab the serial of the machine its run on and paste to cell A1<br>
<br>
This code does work by the way and is accurate (BY THE WAY, IM NEW AT THIS, IAM SURE YOU CAN TELL)<br>
<br>
On Error Resume Next<br>
<br>
Dim System<br>
<br>
If Wscript.Arguments.Count > 0 Then<br>
sSystem = Wscript.Arguments(0)<br>
<br>
End If<br>
<br>
ComputerName = InputBox("Enter the name of the computer you wish to query")<br>
<br>
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//" & ComputerName & ""<br>
<br>
Set SNSet = GetObject(winmgmt1).InstancesOf("Win32_BIOS")<br>
<br>
For Each SN In SNSet<br>
<br>
MsgBox "The serial number for the specified computer is: " & SN.SerialNumber<br>
<br>
Next<br>
<br>
End Sub<br>
<br><br type="_moz">