Before boredom sorted out a copy of this thing, because in the unit to the new employees with the computer, need to register the equipment, can always check the feeling is very troublesome, the results of the following VBS script was born, but unfortunately this script does not come in handy ah ...
The function of this script is to automatically log the related information of the queried computer into a document after running, then upload the generated file to the server after FTP, and finally clear the run script is the generated file and delete itself.
Here's the code:
Copy Code code as follows:
' # # #收集计算机信息_开始 #####
On Error Resume Next
Set fso = CreateObject ("Scripting.FileSystemObject")
Set f1 = fso. CreateTextFile ("info")
StrComputer = "."
If Err.Description = "" Then
' Collect local computer names
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_ComputerSystem", 48)
J = 0
For each objitem in colitems
If J = 0 Then f1.write (Trim (objitem.name)) Else f1.write (Trim (objitem.name)) ' collects local computer name
j = j + 1
Next
' Collect computer login account
F1.write (Chr (10))
F1.write (";")
F1.write (Chr (10))
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_ComputerSystem", 48)
J = 0
For each objitem in colitems
If J = 0 Then f1.write (Trim (objitem.username)) Else f1.write (Trim (objitem.username)) ' Collect computer login account
j = j + 1
Next
' Collect CPU Information
F1.write (Chr (10))
F1.write (";")
F1.write (Chr (10))
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_Processor", 48)
J = 1
For each objitem in colitems
If J = 0 Then f1.write (Trim (objitem.name)) Else f1.write (Trim (objitem.name) & "| |")
j = j + 1
Next
' Collect total memory capacity
F1.write (Chr (10))
F1.write (";")
F1.write (Chr (10))
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_ComputerSystem", 48)
J = 2
For each objitem in colitems
If J = 0 Then f1.write (Trim (objitem.totalphysicalmemory)/1024/1024 & "GB") Else f1.write (Trim (objitem.totalphysical Memory)/1024/1024 & "GB" & "| |")
j = j + 1
Next
' Collect graphics information
F1.write (Chr (10))
F1.write (";")
F1.write (Chr (10))
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_VideoController", 48)
J = 4
For each objitem in colitems
If J = 0 Then f1.write (Trim (objitem.caption) & (objitem.videomodedescription) Else f1.write (Trim (objitem.caption) & Amp (objitem.videomodedescription) & "| |")
j = j + 1
Next
' Collect hard drive basic information
F1.write (Chr (10))
F1.write (";")
F1.write (Chr (10))
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_DiskDrive", 48)
J = 5
For each objitem in colitems
If J = 0 Then f1.write (Trim (Objitem.model) & (objitem.size)/1024/1024/1024 & "GB" & (objitem.partitions)) El Se f1.write (Trim (Objitem.model) & "--" & (Objitem.size)/1024/1024/1024 & "GB" & "--" & (Objitem.part itions) & "| |")
j = j + 1
Next
' Collect sound card information
F1.write (Chr (10))
F1.write (";")
F1.write (Chr (10))
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_sounddevice", 48)
J = 6
For each objitem in colitems
If J = 0 Then f1.write (Trim (objitem.productname)) Else f1.write (Trim (objitem.productname) & "| |")
j = j + 1
Next
' Collect network card information
F1.write (Chr (10))
F1.write (";")
F1.write (Chr (10))
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_NetworkAdapter", 48)
J = 7
For each objitem in colitems
If J = 0 Then f1.write (Trim (Objitem.netconnectionid) & (objitem.description) & (objitem.macaddress) & (Objite M.manufacturer) Else F1.write (Trim (Objitem.netconnectionid) & "--" & (Objitem.productname) & "--" & (ob jitem.macaddress) & "--" & (Objitem.manufacturer) & "| |")
j = j + 1
Next
End If
F1. Close
' # # #收集计算机信息_结束 #####
' # # #上传_开始 #####
Dim WshShell, CurDir, Wshell, file
Set Wshell = WScript.CreateObject ("Shell.Application")
Set WshShell = WScript.CreateObject ("Wscript.Shell")
Set filesystem = WScript.CreateObject ("Scripting.FileSystemObject")
Set outputfile = filesystem.opentextfile ("Upload", 2,true)
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_ComputerSystem", 48)
J = 0
For each objitem in colitems
If J = 0 Then file = "Info" & Trim (objItem.Name) & ". csv" Else file = "Info" & Trim (objItem.Name) &. CS V
j = j + 1
Next
Outputfile.writeline "Open 192.168.0.254 2020"
Outputfile.writeline "User Iplog Iplog"
Outputfile.writeline "put" & File
Outputfile.writeline "Bye"
Outputfile.close
Wshshell.run "Ftp-n-s:upload"
Set Wshell = Nothing
Set WshShell = Nothing
Set filesystem = Nothing
Set outputfile = Nothing
' # # #上传_结束 #####
' # # #自删除_开始 #####
' Wscript.Sleep 2000
' Set obj = CreateObject (' Scripting.FileSystemObject ')
' Obj. DeleteFile ("Upload")
' Obj. DeleteFile ("info")
' Obj. DeleteFile (WScript.ScriptName)
Wscript.Quit (0)
' # # #自删除_结束 #####
Upload to FTP address
Open 192.168.0.254 2020
User Iplog Iplog
Put info mdxy.csv
Bye