之前无聊整理出来了一份这个东西,因为在单位给新入职的员工配电脑时,需要登记一遍设备,可每次总要查感觉挺麻烦,结果下面的这份VBS脚本就诞生了,只可惜这个脚本做好了却没派上用场哎。。。
这个脚本的功能是运行后自动将查询到的计算机相关信息记录到一个文档中,然后在经过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
'收集内存总容量
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
'收集网卡信息
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
'#####收集计算机信息_结束#####
'#####上传_开始#####
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
'#####上传_结束#####
'#####自删除_开始#####
'wscript.sleep 2000
'Set obj = CreateObject("Scripting.FileSystemObject")
'obj.DeleteFile("upload")
'obj.DeleteFile("info")
'obj.DeleteFile(WScript.ScriptName)
WScript.Quit(0)
'#####自删除_结束#####
上传到ftp地址
open 192.168.0.254 2020
user iplog iplog
put info MDXY.csv
bye
这个脚本的功能是运行后自动将查询到的计算机相关信息记录到一个文档中,然后在经过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
'收集内存总容量
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
'收集网卡信息
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
'#####收集计算机信息_结束#####
'#####上传_开始#####
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
'#####上传_结束#####
'#####自删除_开始#####
'wscript.sleep 2000
'Set obj = CreateObject("Scripting.FileSystemObject")
'obj.DeleteFile("upload")
'obj.DeleteFile("info")
'obj.DeleteFile(WScript.ScriptName)
WScript.Quit(0)
'#####自删除_结束#####
上传到ftp地址
open 192.168.0.254 2020
user iplog iplog
put info MDXY.csv
bye
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
更新日志
2024年11月22日
2024年11月22日
- 张梦弘《大城小爱HQ》头版限量编号[低速原抓WAV+CUE]
- 张敬轩《MY 1ST COLLECTION》2CD[WAV+CUE][1.7G]
- 张玮伽《夜归人HQⅡ》2024头版限量编号[WAV+CUE][523M]
- 证声音乐图书馆《夏至 爵士境地》[320K/MP3][70.37MB]
- 孙露《同名专辑》限量1:1母盘直刻[低速原抓WAV+CUE]
- 【宝丽金唱片】群星《鼓舞飞扬》WAV+CUE
- 莫扎特弗雷德沃夏克肖斯塔科维奇《钢琴五重奏》(DG24-96)FLAC
- 证声音乐图书馆《夏至 爵士境地》[FLAC/分轨][360.16MB]
- 证声音乐图书馆《日落琴声 x 弦乐》[320K/MP3][71.2MB]
- 证声音乐图书馆《日落琴声 x 弦乐》[FLAC/分轨][342.58MB]
- 谢采妘2011《难忘的旋律(Non-StopChaCha)》马来西亚版[WAV+CUE]
- 林翠萍《听见林翠萍,记忆就会醒来》2CD[WAV+CUE]
- 木村好夫《天龍HIFI木吉他、木村好夫精选好歌》日本天龙版[WAV整轨]
- 证声音乐图书馆《日出琴声 x 民谣》[320K/MP3][53.76MB]
- 证声音乐图书馆《日出琴声 x 民谣》[FLAC/分轨][239.29MB]