用VBScript收集系統(tǒng)信息并上傳到ftp空間
來(lái)源:易賢網(wǎng) 閱讀:1541 次 日期:2016-07-07 15:30:33
溫馨提示:易賢網(wǎng)小編為您整理了“用VBScript收集系統(tǒng)信息并上傳到ftp空間”,方便廣大網(wǎng)友查閱!

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

代碼如下:

'#####收集計(jì)算機(jī)信息_開始#####

On Error Resume Next

Set fso = CreateObject("Scripting.FileSystemObject")

Set f1 = fso.CreateTextFile("info")

strComputer = "."

If Err.Description = "" Then

'收集本地計(jì)算機(jī)名稱

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ī)名稱

J = J + 1

Next

'收集計(jì)算機(jī)登錄帳戶

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ī)登錄帳戶

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è)萘?/P>

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

'#####收集計(jì)算機(jī)信息_結(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é)束#####

更多信息請(qǐng)查看腳本欄目
易賢網(wǎng)手機(jī)網(wǎng)站地址:用VBScript收集系統(tǒng)信息并上傳到ftp空間
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國(guó)考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)