In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use VBScript to collect system information and upload it to ftp space, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
I was bored to sort out a copy of this thing before, because when the unit equipped the new employees with computers, they needed to register the equipment, but it was always troublesome to check it every time. As a result, the following VBS script was born, but it was a pity that this script did not come in handy.
The function of this script is to automatically record the computer-related information queried into a document after running, then upload the generated file to the server to save after FTP, and finally clear the file generated by the running script and delete itself.
Here is the code:
'# collect computer information _ start #
On Error Resume Next
Set fso = CreateObject ("Scripting.FileSystemObject")
Set F1 = fso.CreateTextFile ("info")
StrComputer = "."
If Err.Description = "" Then
'collect the local computer name
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 names
J = J + 1
Next
'collect computer login accounts
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 GB) Else f1.write (Trim (objItem.TotalPhysicalMemory) / 1024 objItem.TotalPhysicalMemory) & "GB" & "| |")
J = J + 1
Next
'collect video 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_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) & (objItem.VideoModeDescription) & "| |")
J = J + 1
Next
'collect basic information about the hard disk
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 Else f1.write 1024 & "GB" & (objItem.Partitions)) Else f1.write (Trim (objItem.Model) & "-" & (objItem.Size) / 1024 pound 1024 & "GB" & "-" & (objItem.Partitions) & "| |")
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 Nic 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) & (objItem.Manufacturer)) Else f1.write (Trim (objItem.NetConnectionID) & "-" & (objItem.ProductName) & "--(objItem.MACAddress) &"-"& (objItem.Manufacturer) &" | | ")
J = J + 1
Next
End If
F1.Close
'# collect computer information _ end #
'# upload _ start #
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", 2pm 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) & ".csv"
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
'# upload _ end #
'# since deletion _ start #
'wscript.sleep 2000
'Set obj = CreateObject ("Scripting.FileSystemObject")
'obj.DeleteFile ("upload")
'obj.DeleteFile ("info")
'obj.DeleteFile (WScript.ScriptName)
WScript.Quit (0)
'# self-delete _ end #
Upload to ftp address
Open 192.168.0.254 2020
User iplog iplog
Put info MDXY.csv
Bye
Thank you for reading this article carefully. I hope the article "how to use VBScript to collect system information and upload it to ftp space" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.