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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script for PC serial number and hostname.

Status
Not open for further replies.

raquetman75

Technical User
Apr 18, 2003
28
0
0
US
Can anybody help me with a script that will output in a txt file and in it is the computer name, loginame and the PC serial number. Thank you very much.
 
What's wrong with this script? Help..

===================
Dim Model
Dim Name
Dim User
Dim Company
Dim Serial


strComputer = "."

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

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
model=objComputer.Model
Set colBIOS = objWMIService.ExecQuery _
("Select * from Win32_BIOS")
For each objBIOS in colBIOS
serial=objBIOS.SerialNumber
Next
name=objComputer.Name
user=objComputer.Username
company=objComputer.Manufacturer
Next


Set objFSO = CreateObject("Scripting.FileSystemObject")


if objFSO.fileexists("\lic-nap\getsn\" & user & serial & ".txt")=False then

Const ForAppending = 8
Set objFile = objFSO.OpenTextFile("\lic-nap\getsn\userdata.txt", ForAppending)
Set objFile2=objFSO.CreateTextFile("\lic-nap\getsn\" & user & serial & ".txt",True)
DateInfo = DateInfo & Now & VbCrLf
out1="File Created: " & DateInfo
out2="User Name: " & user
out3="Computer Name: " & name
out4="Model: " & model
out5="Serial Number: " & serial
out6="Manufacturer: " & company

objFile2.Writeline out1
objFile2.Writeline out2
objFile2.Writeline out3
objFile2.Writeline out4
objFile2.Writeline out5
objFile2.Writeline out6
objFile.Writeline user & "," & name & "," & model & "," & serial & "," & company
objFile.Close
objFile2.Close


end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top