vbs获取操作系统及其版本号(vbs用cmd)这都可以?

随心笔谈2年前发布 编辑
165 0
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买


Program Name: Get_Remote_PC_Partial_Information.vbs
—-The Code as Below
‘————————–
‘Author By: Wei_Zhu
‘Creation Date: 2010-03-08
‘————————–

On Error Resume Next
Const ForReading=1, ForWriting=2, ForAppending=8
Const TristateUseDefault=-2, TristateTrue=-1, TristateFalse=0

Set objExcel=CreateObject(“Excel.Application”)
Set objWorkbook=objExcel.Workbooks.Add() ‘This is add new
Set objRange=objExcel.Range(“A1″,”E1″)
objRange.Font.Size=10
objrange.Font.Bold=True
objrange.Font.Name=”Times New Roman”
objrange.Cells(1).Value=”Domain”
objrange.Cells(2).Value=”IP”
objrange.Cells(3).Value=”Manufacturer”
objrange.Cells(4).Value=”Model”
objrange.Cells(5).Value=”Serial Number”
objrange.Interior.ColorIndex=34 ‘Set BackColor
objRange.Borders.LineStyle=1
Set objRange=objExcel.ActiveCell.EntireColumn

objRange.AutoFit()

‘—-Auto Fill The Column Width—
Set objcol=objExcel.Columns(“A:E”).EntireColumn
objcol.AutoFit

set ws=createobject(“wscript.shell”)
set fso=createobject(“scripting.filesystemobject”)
set folder=fso.getfolder(ws.CurrentDirectory&”/Computer”)

Set fc=folder.Files
For Each f1 in fc
s=folder&”/” & f1.name
set ts=fso.OpenTextFile(s, ForReading)
lint_line=2
Do While Not ts.AtEndOfStream
l_ip=ts.ReadLine
GetPCInfo l_ip,f1.Name,lint_line
lint_line=lint_line +1
Loop
lint_line=0
ts.Close
Next

objExcel.DisplayAlerts=False ‘Close the Alert
‘objExcel.ActiveWorkBook.Saveas lstg_to_f,-4143
‘msgbox lstg_to_f
objExcel.ActiveWorkBook.Saveas folder&”.xls”,-4143
objExcel.DisplayAlerts=False ”Close the Save Alert
objExcel.ActiveWorkbook.Close
objExcel.DisplayAlerts=False
objExcel.Application.Quit

Function GetPCInfo(ByVal ip, ByVal l_fn, ByVal l_line)
‘Function GetPCInfo(l_fn,l_line)
strComputer=ip
objWMIService=GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!//” & strComputer & “/root/cimv2”)

colItems=objWMIService.ExecQuery(“Select * from Win32_SystemEnclosure”)

l_Array=Split(l_fn, “.”, -1, 1)

For Each objItem In colItems
‘MsgBox “Manufacturer: ” & objItem.Manufacturer
‘ Msgbox “Product: ” & objItem.Product
‘ Msgbox “Serial Number: ” & objItem.SerialNumber

objRange=objExcel.Range(“A” & l_line, “E” & l_line)
objRange.Cells(1).value=l_Array(0)
objRange.Cells(2).value=ip
objRange.Cells(3).value=objItem.Manufacturer
objRange.Cells(4).value=objItem.Model
objRange.Cells(5).value=objItem.SerialNumber
Next
‘—-Auto Fill The Column Width—
objcol=objExcel.Columns(“A:E”).EntireColumn
objcol.AutoFit()

© 版权声明

相关文章