I really don't know a whole lot of anything about VBScript, I'm just dabbling at this point. What I'm trying to do is essentially combine a couple of sample scripts I found to perform the function I need. What I want to do is to be able to get the serial number of a PC on the domain by entering it's computer name in an input box.
Here's a working script I have that'll return the serial number of the computer. In this case it'll return the serial number of the computer named "ACR1234".
And here's a script I found and modified so that it successfullyasks for the input I want. (It just echoes the input back at me as shown here)
What I haven't been able to figure out is how to combine them in a way that the information entered in the InputBox from example 2 lets you replace the "ACR1234" from example 1. I've tried all kinds of things and always get "variable is undefined:'arrComputers". I of course would delete the "Text2 = "You entered:" & vbCrLf", but what in the world do I replace "arrComputers = Array("ACR1234")" with so it fills in the entered text instead of the "ACR1234" in my example?
Here's a working script I have that'll return the serial number of the computer. In this case it'll return the serial number of the computer named "ACR1234".
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("ACR1234")
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "Serial Number: " & objItem.IdentifyingNumber
Next
Next
And here's a script I found and modified so that it successfullyasks for the input I want. (It just echoes the input back at me as shown here)
Option Explicit
Dim Message, result
Dim Title, Text1, Text2
Message = "Please enter a workstation ID"
Title = "Remote serial number search"
Text1 = "User input canceled"
Text2 = "You entered:" & vbCrLf
result = InputBox(Message, Title, "Workstation ID", 100, 100)
If result = "" Then ' Canceled by the user
WScript.Echo Text1
Else
WScript.Echo Text2 & result
End If
'*** End
What I haven't been able to figure out is how to combine them in a way that the information entered in the InputBox from example 2 lets you replace the "ACR1234" from example 1. I've tried all kinds of things and always get "variable is undefined:'arrComputers". I of course would delete the "Text2 = "You entered:" & vbCrLf", but what in the world do I replace "arrComputers = Array("ACR1234")" with so it fills in the entered text instead of the "ACR1234" in my example?