溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

怎么用VBScript收集系統(tǒng)信息并上傳到ftp空間

發(fā)布時間:2021-10-12 09:51:55 來源:億速云 閱讀:250 作者:小新 欄目:開發(fā)技術

這篇文章主要介紹了怎么用VBScript收集系統(tǒng)信息并上傳到ftp空間,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

之前無聊整理出來了一份這個東西,因為在單位給新入職的員工配電腦時,需要登記一遍設備,可每次總要查感覺挺麻煩,結(jié)果下面的這份VBS腳本就誕生了,只可惜這個腳本做好了卻沒派上用場哎。。。

這個腳本的功能是運行后自動將查詢到的計算機相關信息記錄到一個文檔中,然后在經(jīng)過FTP將生成的文件上傳至服務器保存,最后在清除運行腳本是生成的文件并刪除自身。

下面是代碼:


'#####收集計算機信息_開始#####
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("info")
strComputer = "."
If Err.Description = "" Then
'收集本地計算機名稱
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)) '收集本地計算機名稱
J = J + 1
Next
'收集計算機登錄帳戶
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)) '收集計算機登錄帳戶
J = J + 1
Next
'收集CPU信息
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
'收集內(nèi)存總?cè)萘?
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.TotalPhysicalMemory)/1024/1024 & " GB" & "||")
J = J + 1
Next
'收集顯卡信息
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
'收集硬盤基本信息
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)) Else f1.write (Trim(objItem.Model) & "--" & (objItem.Size)/1024/1024/1024 & " GB" & "--" & (objItem.Partitions) & "||")
J = J + 1
Next
'收集聲卡信息
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
'收集網(wǎng)卡信息
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
'#####收集計算機信息_結(jié)束#####
'#####上傳_開始#####
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) & ".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
'#####上傳_結(jié)束#####
'#####自刪除_開始#####
'wscript.sleep 2000
'Set obj = CreateObject("Scripting.FileSystemObject")
'obj.DeleteFile("upload")
'obj.DeleteFile("info")
'obj.DeleteFile(WScript.ScriptName)
WScript.Quit(0)
'#####自刪除_結(jié)束#####


上傳到ftp地址
open 192.168.0.254 2020
user iplog iplog
put info MDXY.csv
bye

感謝你能夠認真閱讀完這篇文章,希望小編分享的“怎么用VBScript收集系統(tǒng)信息并上傳到ftp空間”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業(yè)資訊頻道,更多相關知識等著你來學習!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI