(wmi)获取计算机各类软硬件信息的VBS代码集合
(wmi)获取计算机各类软硬件信息的VBS代码集合
获取计算机各类软硬件信息的VBS代码集合是VBS脚本,按键使用注意哟。
自己不需要属性就删除吧。
可以读取所有物理硬盘!!strComputer = "."Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer _& "\root\cimv2")Set colDiskDrives = objWMIService.ExecQuery _("Select * from Win32_DiskDrive")For each objDiskDrive in colDiskDrivesWscript.Echo "Bytes Per Sector: " & vbTab & _objDiskDrive.BytesPerSectorFor i = Lbound(objDiskDrive.Capabilities) to _Ubound(objDiskDrive.Capabilities)Wscript.Echo "Capabilities: " & vbTab & _objDiskDrive.Capabilities(i)NextWscript.Echo "Caption: " & vbTab & objDiskDrive.CaptionWscript.Echo "Device ID: " & vbTab & objDiskDrive.DeviceIDWscript.Echo "Index: " & vbTab & objDiskDrive.IndexWscript.Echo "Interface Type: " & vbTab & objDiskDrive.InterfaceType Wscript.Echo "Manufacturer: " & vbTab & objDiskDrive.Manufacturer Wscript.Echo "Media Loaded: " & vbTab & objDiskDrive.MediaLoaded Wscript.Echo "Media Type: " & vbTab & objDiskDrive.MediaTypeWscript.Echo "Model: " & vbTab & objDiskDrive.ModelWscript.Echo "Name: " & vbTab & Wscript.Echo "Partitions: " & vbTab & objDiskDrive.PartitionsWscript.Echo "PNP DeviceID: " & vbTab & objDiskDrive.PNPDeviceID Wscript.Echo "SCSI Bus: " & vbTab & objDiskDrive.SCSIBusWscript.Echo "SCSI Logical Unit: " & vbTab & _objDiskDrive.SCSILogicalUnitWscript.Echo "SCSI Port: " & vbTab & objDiskDrive.SCSIPortWscript.Echo "SCSI TargetId: " & vbTab & objDiskDrive.SCSITargetIdWscript.Echo "Sectors Per Track: " & vbTab & _objDiskDrive.SectorsPerTrackWscript.Echo "Signature: " & vbTab & objDiskDrive.SignatureWscript.Echo "Size: " & vbTab & objDiskDrive.SizeWscript.Echo "Status: " & vbTab & objDiskDrive.StatusWscript.Echo "Total Cylinders: " & vbTab & _objDiskDrive.TotalCylindersWscript.Echo "Total Heads: " & vbTab & objDiskDrive.TotalHeadsWscript.Echo "Total Sectors: " & vbTab & objDiskDrive.TotalSectorsWscript.Echo "Total Tracks: " & vbTab & objDiskDrive.TotalTracksWscript.Echo "Tracks Per Cylinder: " & vbTab & _objDiskDrive.TracksPerCylinderNext以上代码是读取物理磁盘信息的,非分区信息。
wmi vbs
换言之,我们不但知道记事本打开了,还知道哪个“文件”(inventory.vbs) 打开了。尽管许多不同的应用程序都会以这种相同的方式运行,出于某种原因,Microsoft Word 或 Excel“不会”如此运行。(但很有趣的是 PowerPoint 会如此运行。)使用 Word 和 Excel 应用程序,可以获得启动程序的 CommandLine,但不能指示打开了哪个文档。而是得到一个如下的普通命令行字符串:
Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.DisplayAlerts = FALSE
Set objWorkbook = objExcel.Workbooks.Open("C:ScriptsTest.xls") Set objWorksheet = objWorkbook.Worksheets(1)
该脚本开始时声明一个名为 MY_COMPUTER 的常量并为其赋值 &H11&;这是 Windows Shell 对象用于定位“我的电脑”的值。然后使用这两行代码确定本地计算机的名称并将其名称存储在 strComputer 变量中:
Set objNetwork = CreateObject("work") strComputer = puterName
"C:Program FilesMicrosoft OfficeOFFICE11EXCEL.EXE" /e
我们一定另找时间研究这个谜。
VB利用GetObject(WinMgmts)获取系统信息
For Each wbemObject In wbemObjectSet
WScript.Echo "物理内存 (MB): " & CInt(wbemObject.TotalPhysicalMemory/1024)
用WMI对象列出系统所有进程:
----Instance.vbs---- 程序代Βιβλιοθήκη Dim WMI,objs
Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_Process")
For Each obj In objs
next
msgbox infor
CPU的序列号:
---CPUID.vbs---
程序代码
Dim cpuInfo
cpuInfo = ""
set moc = GetObject("Winmgmts:").InstancesOf("Win32_Processor")
for each mo in moc
for each mo in moc
HDid = mo.Model
msgbox "硬盘型号为:" & HDid
next
网卡MAC物理地址:
---MACAddress.vbs---
程序代码
Dim mc
C++之WMI编程
C++之WMI编程大家平时在用类似鲁大师之类软件的时候,会看到鲁大师之类的软件能够获取到PC机的硬件的详细信息,有时候自己在写软件的时候也需要获取PC硬件的详细信息,这个时候你会发现有的硬件信息通过系统的API函数无法获取到或者获取的不准确。
所以这个时候就要通过WMI编程来获取硬件信息了。
WMI是windows操作系统用来管理软件和硬件的核心。
其它的不再多讲了,下面来看最主要的,通过WMI获取硬件信息。
整体来说,通过WMI获取计算机硬件信息有以下几个步骤1、用CoInitializeEx函数初始化COM参数。
因为WMI中的类都是基于COM技术的。
2、用CoInitializeSecurity函数初始化COM进程的安全,因为WMI的进程和应用程序进程不在同一个级别。
3、获取IWbemServices指针,通过函数IWbemLocator::ConnectServer获取。
4、通过CoSetProxyBlanket设置IWbemServices代理安全,使WMI服务可以模拟客户端。
5、使用IWbemServices进行WMI查询,主要使用WQL语句。
6、清理COM对象。
例子,查询操作系统信息的一个例子#include"stdafx.h"#include<iostream>using namespace std;#include<comdef.h>#include<Wbemidl.h># pragma comment(lib, "wbemuuid.lib")int_tmain(int argc, _TCHAR* argv[]){HRESULT hres;// Initialize COM.hres = CoInitializeEx(0, COINIT_MULTITHREADED);if (FAILED(hres)){cout << "Failed to initialize COM library. "<< "Error code = 0x"<< hex << hres << endl;return 1; // Program has failed.}// Initializehres = CoInitializeSecurity(NULL,-1, // COM negotiates serviceNULL, // Authentication servicesNULL, // ReservedRPC_C_AUTHN_LEVEL_DEFAULT, // authenticationRPC_C_IMP_LEVEL_IMPERSONATE, // ImpersonationNULL, // Authentication infoEOAC_NONE, // Additional capabilitiesNULL// Reserved);if (FAILED(hres)){cout << "Failed to initialize security. "<< "Error code = 0x"<< hex << hres << endl;CoUninitialize();return 1; // Program has failed.}// Obtain the initial locator to Windows Management// on a particular host computer.IWbemLocator *pLoc = 0;hres = CoCreateInstance(CLSID_WbemLocator,0,CLSCTX_INPROC_SERVER,IID_IWbemLocator, (LPVOID *) &pLoc);if (FAILED(hres)){cout << "Failed to create IWbemLocator object. "<< "Error code = 0x"<< hex << hres << endl;CoUninitialize();return 1; // Program has failed.}IWbemServices *pSvc = 0;// Connect to the root\cimv2 namespace with the// current user and obtain pointer pSvc// to make IWbemServices calls.hres = pLoc->ConnectServer(_bstr_t(L"ROOT\\CIMV2"), // WMI namespaceNULL, // User nameNULL, // User password0, // LocaleNULL, // Security flags0, // Authority0, // Context object&pSvc// IWbemServices proxy);if (FAILED(hres)){cout << "Could not connect. Error code = 0x"<< hex << hres << endl;pLoc->Release();CoUninitialize();return 1; // Program has failed.}cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;// Set the IWbemServices proxy so that impersonation// of the user (client) occurs.hres = CoSetProxyBlanket(pSvc, // the proxy to setRPC_C_AUTHN_WINNT, // authentication serviceRPC_C_AUTHZ_NONE, // authorization serviceNULL, // Server principal nameRPC_C_AUTHN_LEVEL_CALL, // authentication levelRPC_C_IMP_LEVEL_IMPERSONATE, // impersonation levelNULL, // client identityEOAC_NONE// proxy capabilities);if (FAILED(hres)){cout << "Could not set proxy blanket. Error code = 0x"<< hex << hres << endl;pSvc->Release();pLoc->Release();CoUninitialize();return 1; // Program has failed.}IEnumWbemClassObject* pEnumerator = NULL;hres = pSvc->ExecQuery(bstr_t("WQL"),bstr_t("SELECT * FROM Win32_OperatingSystem"),WBEM_FLAG_FORWARD_ONLY |WBEM_FLAG_RETURN_IMMEDIATELY,NULL,&pEnumerator);if (FAILED(hres)){cout << "Query for processes failed. "<< "Error code = 0x"<< hex << hres << endl;pSvc->Release();pLoc->Release();CoUninitialize();return 1; // Program has failed.}else{IWbemClassObject *pclsObj;ULONG uReturn = 0;while (pEnumerator){hres = pEnumerator->Next(WBEM_INFINITE, 1,&pclsObj, &uReturn);if(0 == uReturn){break;}VARIANT vtProp;// Get the value of the Name propertyhres = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);wcout << "Manufacturer Name : " << vtProp.bstrVal << endl;VariantClear(&vtProp);}}// Cleanup// ========pSvc->Release();pLoc->Release();CoUninitialize();return 0;}其它的查询可以修改WQL语句来实现。
Windows操作系统电脑的运行代码大全
Windows操作系统电脑的运⾏代码⼤全CMD命令使⽤⽅法:开始->运⾏->键⼊cmd、或者win键+R->键⼊cmdgpedit.msc—–组策略sndrec32——-录⾳机Nslookup——-IP地址侦测器explorer——-打开资源管理器logoff———注销命令tsshutdn——-60秒倒计时关机命令lusrmgr.msc—-本机⽤户和组services.msc—本地服务设置oobe/msoobe /a—-检查XP是否激活notepad——–打开记事本cleanmgr——-垃圾整理net start messenger—-开始信使服务compmgmt.msc—计算机管理net stop messenger—–停⽌信使服务conf———–启动netmeetingdvdplay——–DVD播放器charmap——–启动字符映射表diskmgmt.msc—磁盘管理实⽤程序calc———–启动计算器dfrg.msc——-磁盘碎⽚整理程序chkdsk.exe—–Chkdsk磁盘检查devmgmt.msc— 设备管理器regsvr32 /u *.dll—-停⽌dll⽂件运⾏drwtsn32—— 系统医⽣rononce -p —-15秒关机dxdiag———检查DirectX信息regedt32——-注册表编辑器Msconfig.exe—系统配置实⽤程序rsop.msc——-组策略结果集mem.exe——–显⽰内存使⽤情况regedit.exe—-注册表winchat——–XP⾃带局域⽹聊天progman——–程序管理器winmsd———系统信息perfmon.msc—-计算机性能监测程序winver———检查Windows版本sfc /scannow—–扫描错误并复原taskmgr—–任务管理器(2000/xp/2003)winver———检查Windows版本wmimgmt.msc—-打开windows管理体系结构(WMI)wupdmgr——–windows更新程序wscript——–windows脚本宿主设置write———-写字板winmsd———系统信息wiaacmgr——-扫描仪和照相机向导winchat——–XP⾃带局域⽹聊天mem.exe——–显⽰内存使⽤情况Msconfig.exe—系统配置实⽤程序mplayer2——-简易widnows media playermspaint——–画图板mstsc———-远程桌⾯连接mplayer2——-媒体播放机magnify——–放⼤镜实⽤程序mmc————打开控制台mobsync——–同步命令dxdiag———检查DirectX信息drwtsn32—— 系统医⽣devmgmt.msc— 设备管理器dfrg.msc——-磁盘碎⽚整理程序diskmgmt.msc—磁盘管理实⽤程序dcomcnfg——-打开系统组件服务ddeshare——-打开DDE共享设置dvdplay——–DVD播放器net stop messenger—–停⽌信使服务net start messenger—-开始信使服务notepad——–打开记事本nslookup——-⽹络管理的⼯具向导ntbackup——-系统备份和还原narrator——-屏幕“讲述⼈”ntmsmgr.msc—-移动存储管理器ntmsoprq.msc—移动存储管理员操作请求netstat -an—-(TC)命令检查接⼝syncapp——–创建⼀个公⽂包sysedit——–系统配置编辑器sigverif——-⽂件签名验证程序sndrec32——-录⾳机shrpubw——–创建共享⽂件夹secpol.msc—–本地安全策略syskey———系统加密,⼀旦加密就不能解开,保护windows xp系统的双重密码services.msc—本地服务设置Sndvol32——-⾳量控制程序sfc.exe——–系统⽂件检查器sfc /scannow—windows⽂件保护tsshutdn——-60秒倒计时关机命令tourstart——xp简介(安装完成后出现的漫游xp程序)taskmgr——–任务管理器eventvwr——-事件查看器eudcedit——-造字程序explorer——-打开资源管理器packager——-对象包装程序perfmon.msc—-计算机性能监测程序progman——–程序管理器regedit.exe—-注册表rsop.msc——-组策略结果集regedt32——-注册表编辑器rononce -p —-15秒关机regsvr32 /u *.dll—-停⽌dll⽂件运⾏regsvr32 /u zipfldr.dll——取消ZIP⽀持cmd.exe——–CMD命令提⽰符chkdsk.exe—–Chkdsk磁盘检查certmgr.msc—-证书管理实⽤程序calc———–启动计算器charmap——–启动字符映射表cliconfg——-SQL SERVER 客户端⽹络实⽤程序Clipbrd——–剪贴板查看器conf———–启动netmeetingcompmgmt.msc—计算机管理cleanmgr——-垃圾整理ciadv.msc——索引服务程序osk————打开屏幕键盘odbcad32——-ODBC数据源管理器oobe/msoobe /a—-检查XP是否激活lusrmgr.msc—-本机⽤户和组logoff———注销命令iexpress——-⽊马捆绑⼯具,系统⾃带Nslookup——-IP地址侦测器fsmgmt.msc—–共享⽂件夹管理器utilman——–辅助⼯具管理器explorer——-打开资源管理器。
C++之WMI编程
C++之WMI编程大家平时在用类似鲁大师之类软件的时候,会看到鲁大师之类的软件能够获取到PC机的硬件的详细信息,有时候自己在写软件的时候也需要获取PC硬件的详细信息,这个时候你会发现有的硬件信息通过系统的API函数无法获取到或者获取的不准确。
所以这个时候就要通过WMI编程来获取硬件信息了。
WMI是windows操作系统用来管理软件和硬件的核心。
其它的不再多讲了,下面来看最主要的,通过WMI获取硬件信息。
整体来说,通过WMI获取计算机硬件信息有以下几个步骤1、用CoInitializeEx函数初始化COM参数。
因为WMI中的类都是基于COM技术的。
2、用CoInitializeSecurity函数初始化COM进程的安全,因为WMI的进程和应用程序进程不在同一个级别。
3、获取IWbemServices指针,通过函数IWbemLocator::ConnectServer获取。
4、通过CoSetProxyBlanket设置IWbemServices代理安全,使WMI服务可以模拟客户端。
5、使用IWbemServices进行WMI查询,主要使用WQL语句。
6、清理COM对象。
例子,查询操作系统信息的一个例子#include"stdafx.h"#include<iostream>using namespace std;#include<comdef.h>#include<Wbemidl.h># pragma comment(lib, "wbemuuid.lib")int_tmain(int argc, _TCHAR* argv[]){HRESULT hres;// Initialize COM.hres = CoInitializeEx(0, COINIT_MULTITHREADED);if (FAILED(hres)){cout << "Failed to initialize COM library. "<< "Error code = 0x"<< hex << hres << endl;return 1; // Program has failed.}// Initializehres = CoInitializeSecurity(NULL,-1, // COM negotiates serviceNULL, // Authentication servicesNULL, // ReservedRPC_C_AUTHN_LEVEL_DEFAULT, // authenticationRPC_C_IMP_LEVEL_IMPERSONATE, // ImpersonationNULL, // Authentication infoEOAC_NONE, // Additional capabilitiesNULL// Reserved);if (FAILED(hres)){cout << "Failed to initialize security. "<< "Error code = 0x"<< hex << hres << endl;CoUninitialize();return 1; // Program has failed.}// Obtain the initial locator to Windows Management// on a particular host computer.IWbemLocator *pLoc = 0;hres = CoCreateInstance(CLSID_WbemLocator,0,CLSCTX_INPROC_SERVER,IID_IWbemLocator, (LPVOID *) &pLoc);if (FAILED(hres)){cout << "Failed to create IWbemLocator object. "<< "Error code = 0x"<< hex << hres << endl;CoUninitialize();return 1; // Program has failed.}IWbemServices *pSvc = 0;// Connect to the root\cimv2 namespace with the// current user and obtain pointer pSvc// to make IWbemServices calls.hres = pLoc->ConnectServer(_bstr_t(L"ROOT\\CIMV2"), // WMI namespaceNULL, // User nameNULL, // User password0, // LocaleNULL, // Security flags0, // Authority0, // Context object&pSvc// IWbemServices proxy);if (FAILED(hres)){cout << "Could not connect. Error code = 0x"<< hex << hres << endl;pLoc->Release();CoUninitialize();return 1; // Program has failed.}cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;// Set the IWbemServices proxy so that impersonation// of the user (client) occurs.hres = CoSetProxyBlanket(pSvc, // the proxy to setRPC_C_AUTHN_WINNT, // authentication serviceRPC_C_AUTHZ_NONE, // authorization serviceNULL, // Server principal nameRPC_C_AUTHN_LEVEL_CALL, // authentication levelRPC_C_IMP_LEVEL_IMPERSONATE, // impersonation levelNULL, // client identityEOAC_NONE// proxy capabilities);if (FAILED(hres)){cout << "Could not set proxy blanket. Error code = 0x"<< hex << hres << endl;pSvc->Release();pLoc->Release();CoUninitialize();return 1; // Program has failed.}IEnumWbemClassObject* pEnumerator = NULL;hres = pSvc->ExecQuery(bstr_t("WQL"),bstr_t("SELECT * FROM Win32_OperatingSystem"),WBEM_FLAG_FORWARD_ONLY |WBEM_FLAG_RETURN_IMMEDIATELY,NULL,&pEnumerator);if (FAILED(hres)){cout << "Query for processes failed. "<< "Error code = 0x"<< hex << hres << endl;pSvc->Release();pLoc->Release();CoUninitialize();return 1; // Program has failed.}else{IWbemClassObject *pclsObj;ULONG uReturn = 0;while (pEnumerator){hres = pEnumerator->Next(WBEM_INFINITE, 1,&pclsObj, &uReturn);if(0 == uReturn){break;}VARIANT vtProp;// Get the value of the Name propertyhres = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);wcout << "Manufacturer Name : " << vtProp.bstrVal << endl;VariantClear(&vtProp);}}// Cleanup// ========pSvc->Release();pLoc->Release();CoUninitialize();return 0;}其它的查询可以修改WQL语句来实现。
VBS脚本使用WMI操作注册表
VBS脚本使用WMI操作注册表1.'VBS脚本使用WMI操作注册表,从微软弄下来的,整理了一下,弄成最简版,简版,常用版,以便与快速查找。
2.oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath3.4.oReg.SetExpandedStringValue HKEY_LOCAL_MACHINE,str KeyPath,strValueName,strValue5.oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,s trValueName,strValue6.oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPat h,strValueName,dwValue7.oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strPath,strV alueName,uBinary8.oReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyP ath,strValueName,arrStringValues9.10.oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath11.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trStringValueName12.13.oReg.GetExpandedStringValue HKEY_LOCAL_MACHIN E,strKeyPath,strValueName,strValue14.oReg.GetDWORDValue HKEY_CURRENT_USER,strKeyP ath,strValueName,dwValue15.oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPa th,strValueName,strValue16.oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPa th,strValueName,uBinary17.oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,arrStringValues18.19.'-------------------------------------------------------------------------------------------20.21.Const HKEY_CLASSES_ROOT = &H8000000022.Const HKEY_CURRENT_USER = &H8000000123.Const HKEY_LOCAL_MACHINE = &H8000000224.Const HKEY_USERS = &H8000000325.Const HKEY_CURRENT_CONFIG = &H8000000526.27.' 创建注册表项28.const HKEY_LOCAL_MACHINE = &H8000000229.strComputer = "."30.Set StdOut = WScript.StdOut31.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_32.strComputer & "\root\default:StdRegProv")33.strKeyPath = "SOFTWARE\System Admin Scripting Gui de"34.oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath35.36.'创建多字符串值37.const HKEY_LOCAL_MACHINE = &H8000000238.strComputer = "."39.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_40.strComputer & "\root\default:StdRegProv")41.strKeyPath = "SOFTWARE\System Admin Scripting Gui de"42.strValueName = "Multi String Value Name"43.arrStringValues = Array("first string", "second string",_44."third string", "fourth string")45.oReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strK eyPath,_46.strValueName,arrStringValues47.48.49.'创建扩展的字符串值50.const HKEY_LOCAL_MACHINE = &H8000000251.strComputer = "."52.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_53.strComputer & "\root\default:StdRegProv")54.strKeyPath = "SOFTWARE\System Admin Scripting Gui de"55.strValueName = "Expanded String Value Name"56.strValue = "%PATHEXT%"57.oReg.SetExpandedStringValue HKEY_LOCAL_MACHINE ,strKeyPath,strValueName,strValue58.59.'创建字符串和 DWORD 值60.const HKEY_LOCAL_MACHINE = &H8000000261.strComputer = "."62.Set StdOut = WScript.StdOut63.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_64.strComputer & "\root\default:StdRegProv")65.strKeyPath = "SOFTWARE\System Admin Scripting Guide"66.strValueName = "String Value Name"67.strValue = "string value"68.oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPat h,strValueName,strValue69.strValueName = "DWORD Value Name"70.dwValue = 8271.oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKey Path,strValueName,dwValue72.73.74.75.'删除注册表项76.77.const HKEY_LOCAL_MACHINE = &H8000000278.strComputer = "."79.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_80.strComputer & "\root\default:StdRegProv")81.strKeyPath = "SOFTWARE\System Admin Scripting Gui de"82.oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath83.84.85.'删除注册表值86.87.const HKEY_LOCAL_MACHINE = &H8000000288.strComputer = "."89.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_90.strComputer & "\root\default:StdRegProv")91.strKeyPath = "SOFTWARE\System Admin Scripting Gui de"92.strDWORDValueName = "DWORD Value Name"93.strExpandedStringValueName = "Expanded String Val ue Name"94.strMultiStringValueName = "Multi String Value Name"95.strStringValueName = "String Value Name"96.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trDWORDValueName97.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trExpandedStringValueName98.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trMultiStringValueName99.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trStringValueName100.101.102.'枚举注册表值和类型103.'枚举子项104.'列出注册表文件105.'监视注册表子项事件106.'监视注册表子树事件107.'读取二进制注册表值108.109.const HKEY_LOCAL_MACHINE = &H80000002110.strComputer = "."111.Set StdOut = WScript.StdOut112.Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_113.strComputer & "\root\default:StdRegProv")114.strKeyPath = "SOFTWARE\Microsoft\Windows NT\Cur rentVersion"115.strValueName = "LicenseInfo"116.oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPa th,_117.strValueName,strValue118.For i = lBound(strValue) to uBound(strValue)119.StdOut.WriteLine strValue(i)120.Next121.122.'读取 MultiString 值123.const HKEY_LOCAL_MACHINE = &H80000002124.strComputer = "."125.Set StdOut = WScript.StdOut126.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_127.strComputer & "\root\default:StdRegProv")128.strKeyPath = "SYSTEM\CurrentControlSet\Services\Ev entlog\System"129.strValueName = "Sources"130.oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,str KeyPath,_131.strValueName,arrValues132.For Each strValue In arrValues133.StdOut.WriteLine strValue134.Next135.136.137.138.'读取扩展的字符串值139.const HKEY_LOCAL_MACHINE = &H80000002140.strComputer = "."141.Set StdOut = WScript.StdOut142.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_143.strComputer & "\root\default:StdRegProv")144.strKeyPath = "SOFTWARE\Microsoft\Windows NT\Cur rentVersion\WinLogon"145.strValueName = "UIHost"146.oReg.GetExpandedStringValue HKEY_LOCAL_MACHIN E,strKeyPath,_147.strValueName,strValue148.StdOut.WriteLine "The Windows logon UI host is: " & strValue149.150.151.152.'读取字符串和 DWORD 值153.154.const HKEY_CURRENT_USER = &H80000001155.const HKEY_LOCAL_MACHINE = &H80000002156.strComputer = "."157.Set StdOut = WScript.StdOut158.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" &_159.strComputer & "\root\default:StdRegProv")160.strKeyPath = "Console"161.strValueName = "HistoryBufferSize"162.oReg.GetDWORDValue HKEY_CURRENT_USER,strKeyP ath,strValueName,dwValue163.StdOut.WriteLine "Current History Buffer Size: " & dw Value164.strKeyPath = "SOFTWARE\Microsoft\Windows Script Host\Settings"165.strValueName = "TrustPolicy"166.oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPa th,strValueName,strValue167.StdOut.WriteLine "Current WSH Trust Policy Value: " & strValue168.169.'-------------------------------------------------------------------------------------------170.171.Const HKEY_CLASSES_ROOT = &H80000000172.Const HKEY_CURRENT_USER = &H80000001173.Const HKEY_LOCAL_MACHINE = &H80000002174.Const HKEY_USERS = &H80000003175.Const HKEY_CURRENT_CONFIG = &H80000005176.177.strComputer = "."178.Set StdOut = WScript.StdOut179.Set oReg=GetObject("winmgmts:{impersonationLevel =impersonate}!\\" & strComputer & "\root\default:StdRegProv" )180.181.182.183.'创建注册表项184.strKeyPath = "SOFTWARE\System Admin Scripting Gui de"185.oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath 186.187.'创建多字符串值188.189.strValueName = "Multi String Value Name"190.arrStringValues = Array("first string", "second string", " third string", "fourth string")191.oReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strK eyPath,strValueName,arrStringValues192.193.'创建扩展的字符串值194.strValueName = "Expanded String Value Name"195.strValue = "%PATHEXT%"196.oReg.SetExpandedStringValue HKEY_LOCAL_MACHINE ,strKeyPath,strValueName,strValue197.198.'创建字符串199.strValueName = "String Value Name"200.strValue = "string value"201.oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPat h,strValueName,strValue202.203.'创建DWORD 值204.strValueName = "DWORD Value Name"205.dwValue = 82206.oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKey Path,strValueName,dwValue207.208.'创建二进制值209.strValueName = "Binary Value Name"210.uBinary = Array(1,0,0,0)211.oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strPath,s trValueName,uBinary212.213.214.'删除注册表项215.strKeyPath = "SOFTWARE\System Admin Scripting Gui de"216.oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath 217.218.219.'删除注册表值220.221.strDWORDValueName = "DWORD Value Name"222.strExpandedStringValueName = "Expanded String Val ue Name"223.strMultiStringValueName = "Multi String Value Name"224.strStringValueName = "String Value Name"225.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trDWORDValueName226.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trExpandedStringValueName227.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trMultiStringValueName228.oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,s trStringValueName229.230.231.'''''''''''''''''''''''''''''''''''''''''''''''''枚举注册表值和类型232.'''''''''''''''''''''''''''''''''''''''''''''''''枚举子项233.'''''''''''''''''''''''''''''''''''''''''''''''''列出注册表文件234.'''''''''''''''''''''''''''''''''''''''''''''''''监视注册表子项事件235.'''''''''''''''''''''''''''''''''''''''''''''''''监视注册表子树事件236.237.'读取 MultiString 值238.strKeyPath = "SYSTEM\CurrentControlSet\Services\Ev entlog\System"239.strValueName = "Sources"240.oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,str KeyPath,strValueName,arrValues241.For Each strValue In arrValues242.StdOut.WriteLine strValue243.Next244.245.'读取扩展的字符串值246.strKeyPath = "SOFTWARE\Microsoft\Windows NT\Cur rentVersion\WinLogon"247.strValueName = "UIHost"248.oReg.GetExpandedStringValue HKEY_LOCAL_MACHIN E,strKeyPath,strValueName,strValue249.StdOut.WriteLine "The Windows logon UI host is: " & strValue250.251.'读取字符串值252.strKeyPath = "Console"253.strValueName = "HistoryBufferSize"254.oReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue255.StdOut.WriteLine "Current History Buffer Size: " & dw Value256.257.'读取 DWORD 值258.strKeyPath = "SOFTWARE\Microsoft\Windows Script Host\Settings"259.strValueName = "TrustPolicy"260.oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPa th,strValueName,strValue261.StdOut.WriteLine "Current WSH Trust Policy Value: " & strValue262.263.'读取二进制注册表值264.strKeyPath = "SOFTWARE\Microsoft\Windows NT\Cur rentVersion"265.strValueName = "LicenseInfo"266.oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPa th,strValueName,strValue267.For i = lBound(strValue) to uBound(strValue)268.StdOut.WriteLine strValue(i)269.Next。
VBS常用代码合集
VBS常用代码合集(个人整理)从系统开始菜单中删除此链接:复制代码代码如下:Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT/CLSID/{2559a1f6-21d7-11d4-bdaf-00c04f60b9f0}]@=-"InfoTip"=-[HKEY_CLASSES_ROOT/CLSID/{2559a1f6-21d7-11d4-bdaf-00c04f60b9f0}/DefaultIcon] @=-[HKEY_CLASSES_ROOT/CLSID/{2559a1f6-21d7-11d4-bdaf-00c04f60b9f0}/Instance/Init PropertyBag]"Command"=-"Param1"=-VBS脚本实现整理磁盘碎片功能Set WshShell = WScript.CreateObject("WScript.Shell")Dim fso, d, dcSet fso = CreateObject("Scripting.FileSystemObject")Set dc = fso.DrivesFor Each d in dcIf d.DriveType = 2 ThenReturn = WshShell.Run("defrag " & d & " -f", 1, TRUE)End IfNextSet WshShell = Nothing计划任务定时调用VBS脚本复制代码代码如下:Option ExplicitOn Error Resume Next'生成列表的文件类型Const sListFileType = "wmv,rm,wma"'文件所在的相对路径Const sShowPath="."'排序类型的常量定义Const iOrderFieldFileName = 0Const iOrderFieldFileExt = 1Const iOrderFieldFileSize = 2Const iOrderFieldFileType = 3Const iOrderFieldFileDate = 4'排序顺逆的常量定义const iOrderAsc = 0const iOrderDesc = 1'生成列表的文件数量const iShowCount = 20'显示的日期格式函数Function Cndate2(date1,intDateStyle)dim strdate,dDate1strdate=cstr(date1)If Isdate(strdate) ThenIf Left(cstr(strdate),1)="0" ThendDate1=Cdate("20"+cstr(strdate))elsedDate1=Cdate(strdate)End IfElsedDate1=Now()End IfSelect case intDateStyleCase 1:Cndate2 = Cstr(Year(dDate1))+"-"+Cstr(Month(dDate1))+"-"+Cstr(Day(dDate1))Case 2:Cndate2 = Cstr(Month(dDate1))+"-"+Cstr(Day(dDate1))Case 3:Cndate2 = Cstr(Month(dDate1))+"月"+Cstr(Day(dDate1))+"日"Case 4:Cndate2 = Cstr(year(dDate1))+"年"+ Cstr(Month(dDate1))+"月"+Cstr(Day(dDate1))+"日" End SelectEnd FunctionFunction ListFile(strFiletype,intCompare,intOrder,intShowCount) Dim sListFileDim fso, f, f1, fc, s,ftype,fcount,i,j,kDim t1,t2,t3,t4,t5Dim iMonth,iDaysListFile = ""Set fso = CreateObject("Scripting.FileSystemObject")Set f = fso.GetFolder(sShowPath)Set fc = f.Filesfcount = fc.countredim arrFiles(fcount,5)redim arrFiles2(fcount,5)i=0'排序For Each f1 in fcftype = right(,len()-instrrev(,"."))arrFiles(i,0) = arrFiles(i,1) = ftypearrFiles(i,2) = f1.sizearrFiles(i,3) = f1.typearrFiles(i,4) = f1.DateLastModifiedi=i+1NextFor i=0 to fcount-1for j=i+1 to fcount-1select Case intCompareCase iOrderFieldFileName,iOrderFieldFileExt,iOrderFieldFileType: If arrFiles(i,intCompare)>arrFiles(j,intCompare) thent1 = arrFiles(i,0)t2 = arrFiles(i,1)t3 = arrFiles(i,2)t4 = arrFiles(i,3)t5 = arrFiles(i,4)arrFiles(i,0) = arrFiles(j,0)arrFiles(i,1) = arrFiles(j,1)arrFiles(i,3) = arrFiles(j,3)arrFiles(i,4) = arrFiles(j,4)arrFiles(j,0) = t1arrFiles(j,1) = t2arrFiles(j,2) = t3arrFiles(j,3) = t4arrFiles(j,4) = t5end ifCase iOrderFieldFileSize:If cdbl(arrFiles(i,intCompare))>cdbl(arrFiles(j,intCompare)) thent1 = arrFiles(i,0)t2 = arrFiles(i,1)t3 = arrFiles(i,2)t4 = arrFiles(i,3)t5 = arrFiles(i,4)arrFiles(i,0) = arrFiles(j,0)arrFiles(i,1) = arrFiles(j,1)arrFiles(i,2) = arrFiles(j,2)arrFiles(i,3) = arrFiles(j,3)arrFiles(i,4) = arrFiles(j,4)arrFiles(j,0) = t1arrFiles(j,1) = t2arrFiles(j,2) = t3arrFiles(j,3) = t4arrFiles(j,4) = t5end ifCase iOrderFieldFileDate:If Cdate(arrFiles(i,intCompare))>Cdate(arrFiles(j,intCompare)) then t1 = arrFiles(i,0)t2 = arrFiles(i,1)t3 = arrFiles(i,2)t4 = arrFiles(i,3)t5 = arrFiles(i,4)arrFiles(i,0) = arrFiles(j,0)arrFiles(i,2) = arrFiles(j,2)arrFiles(i,3) = arrFiles(j,3)arrFiles(i,4) = arrFiles(j,4)arrFiles(j,0) = t1arrFiles(j,1) = t2arrFiles(j,2) = t3arrFiles(j,3) = t4arrFiles(j,4) = t5end ifEnd Selectnextnext'生成列表sListFile = sListFile + ("<table cellpadding=0 cellspacing=0 width=100% align=center class=""PageListTable"" style=""BEHAVIOR: url(images/sort2.htc); "">")sListFile = sListFile + ("<THEAD><Tr class=PageListTitleTr><Td class=PageListTitleTd>") sListFile = sListFile + ("名称")sListFile = sListFile + ("</td><Td class=PageListTitleTd>")sListFile = sListFile + ("媒体")sListFile = sListFile + ("</td><Td class=PageListTitleTd>")sListFile = sListFile + ("大小")sListFile = sListFile + ("</td><Td class=PageListTitleTd>")sListFile = sListFile + ("类型")sListFile = sListFile + ("</td><Td class=PageListTitleTd ID=updatetime>")sListFile = sListFile + ("更新时间")sListFile = sListFile + ("</td></Tr></THEAD>")dim iLoopStart,iLoofEnd,iLoopStepIf intOrder = 0 theniLoopStart = 0iLoofEnd = fcount-1iLoopStep = 1ElseiLoopStart = fcount-1iLoofEnd = 0iLoopStep = -1End ifdim iCount,sTDStyleClassiCount = 1For j=iLoopStart to iLoofEnd Step iLoopStepIf instr(strFiletype,arrFiles(j,1))>0 and iCount<=intShowCount then sTDStyleClass = "PageListTd"+Cstr((iCount mod 2)+1)sListFile = sListFile + ("<Tr class=PageListTr><Td class="+sTDStyleClass+">") sListFile = sListFile + ("<img src=images/"+arrFiles(j,1)+".gif align=absbottom><img src=b.gif width=2 height=0><a href=" & sShowPath & "/" & CStr(arrFiles(j,0)) &">" & arrFiles(j,0) &"</a>")If datediff("h",arrFiles(j,4),now)<=24 thensListFile = sListFile + "<img src=images/new.gif align=absmiddle>"end ifsListFile = sListFile + "</td><Td class="+sTDStyleClass+">"sListFile = sListFile + ("<a href=" & sShowPath & "/" & CStr(arrFiles(j,0)) &">")'根据文件名规则,生成中文提示select case left(arrFiles(j,0),3)case "sc2":sListFile = sListFile + "<font color=#AA0000>四川卫视"case "sd2":sListFile = sListFile + "<font color=#00AA00>山东卫视"case "gd2":sListFile = sListFile + "<font color=#0000AA>广东卫视"case "gx2":sListFile = sListFile + "<font color=#AAAA00>广西卫视"end select'日期显示If isnumeric(left(right(arrFiles(j,0),8),2)) theniMonth = cint(left(right(arrFiles(j,0),8),2))iDay = cint(left(right(arrFiles(j,0),6),2))sListFile = sListFile + cstr(iMonth)+"月" + cstr(iDay)+"日"sListFile = sListFile + ("</a></td><Td class="+sTDStyleClass+" align=right>")Elseresponse.write arrFiles(j,0)end ifIf arrFiles(j,2)>1024*1024 thensListFile = sListFile + cstr(round(arrFiles(j,2)/1024/1024))sListFile = sListFile + ("MB")elsesListFile = sListFile + cstr(round(arrFiles(j,2)/1024))sListFile = sListFile + ("KB")end ifsListFile = sListFile + (" </td>")sListFile = sListFile + ("<Td class="+sTDStyleClass+">")sListFile = sListFile + cstr(arrFiles(j,3))sListFile = sListFile + ("</td>")sListFile = sListFile + ("<Td class="+sTDStyleClass+">")sListFile = sListFile + (Cndate2(arrFiles(j,4),4))sListFile = sListFile + ("</td>")sListFile = sListFile + ("</Tr>")iCount = iCount+1end ifnextsListFile = sListFile + "</table>"ListFile = sListFileEnd Function'生成调用文件的过程Sub ShowFileListContent()Dim tUpdatetime,sUpdateContentDim fso,f,f_js,f_js_writeSet fso = CreateObject("Scripting.FileSystemObject")Set f = fso.GetFolder(sShowPath)Set f_js = fso.GetFile("list.js")'比较调用文件与文件夹的最后修改时间If f.DateLastModified<>f_js.DateLastModified thensUpdateContent = ListFile(sListFileType,iOrderFieldFileDate,iOrderDesc,iShowCount) Set f_js_write = fso.CreateTextFile("list.js", True)'JS调用就加上下面这对document.write' f_js_write.Write ("document.write('")f_js_write.Write (sUpdateContent)' f_js_write.Write ("')")f_js_write.CloseEnd IfEnd SubCall ShowFileListContent()可以代替网通宽带登陆器的一段vbs脚本Dim WshShell, iexplorePath, iexploreselectiexplorePath="c:/Progra~1/Intern~1/iexplore.exe"Set WshShell=WScript.CreateObject("WScript.Shell")WshShell.Run iexplorePathWScript.Sleep 2000WshShell.AppActivate "用户上网登陆"WshShell.SendKeys "自己的账号{TAB}"WshShell.SendKeys "自己的密码"WScript.Sleep 2000WshShell.SendKeys "{ENTER}"利用VBS脚本创建快捷方式我们以"QQ Aqing增强包参数配置器"为例子,讲述如何利用VBS脚本创建快捷方式.代码如下:代码:set WshShell = Wscript.CreateObject("Wscript.Shell")strDesktop = WshShell.SpecialFolders("Desktop")set oShellLink = WshShell.CreateShortcut(strDesktop & "/QQ Aqing增强包参数配置器.lnk")'创建一个快捷方式对象,其在桌面上显示的名字为"QQ Aqing增强包参数配置器" oShellLink.TargetPath = "C:/Program Files/Tencent/QQ/Aqing.exe"'设置快捷方式的执行路径oShellLink.WindowStyle = 1oShellLink.Hotkey = "Ctrl+Alt+e" '设置快捷方式的快捷键oShellLink.IconLocation = "E:/Picture/Aqing.ico" '设置快捷方式的图标路径oShellLink.Description = "QQ Aqing增强包参数配置器" '设置快捷方式的描述oShellLink.WorkingDirectory = strDesktopoShellLink.Save将上述代码保存为"CreateShortcut.vbs"(不含引号).双击CreateShortcut.vbs,就会将QQAqing增强包参数配置器的快捷方式建立到桌面上.用这种方法建立的快捷方式的最大优点是:快捷方式的图标可以根据自己的喜好进行更改用VBS脚本发送email![code]Set objEmail = CreateObject("CDO.Message")objEmail.From = "null_vbt@"objEmail.To = "null_vbt@"objEmail.Subject = "这封邮件是由VBS脚本发送"objEmail.Textbody = "如果你收到这封邮件,就表示测试成功!"objEmail.Send利用vbs脚本编写Windows XP/2003序列号更改器复制代码代码如下:ON ERROR RESUME NEXTDim VOL_PROD_KEYif Wscript.arguments.count<1 thenVOL_PROD_KEY =InputBox("使用说明(OEM版无效):"&vbCr&vbCr&" 本脚本程序将修改当前Windows 的序列号。
扫描局域网硬件信息的 VBS
扫描局域网硬件信息的 VBS2009-03-12 14:22扫描局域网硬件信息的 VBS==================================================================== ===='本脚本的功能是检测硬件的信息.On Error Resume Nexttemp=0set wshshell=wscript.createobject("wscript.shell")'启动WMI服务wshshell.run ("%comspec% /c regsvr32 /s scrrun.dll"),0,True wshshell.run ("%comspec% /c sc config winmgmt start= auto"),0,True wshshell.run ("%comspec% /c net start winmgmt"),0strComputer = "."Set objWMIService = Getobject("winmgmts:\\" & strComputer &"\root\cimv2")'用一个文本来记录硬件信息Set WshNetwork = WScript.Createobject("work") computername=puterNameset fso=createobject("scripting.filesystemobject")tempfilter=("\\saves\11\kk\"& computername &".txt")set tempfile=fso.createtextfile(tempfilter)'主板set board =objwmiservice.execQuery("select * from win32_baseboard") for each item in boardboard2="主板: " & item.Productnexttempfile.writeline(board2)'CPUset cpu =objwmiservice.execQuery("select * from win32_processor") for each item in cpucpu2= "CPU : " & nexttempfile.writeline(cpu2)'内存Set colItems = objWMIService.ExecQuery("Select * fromWin32_PhysicalMemory",,48)For Each objItem in colItemsa=objitem.capacity/1048576temp=temp+objitem.capacityn=n+1Nextmemory=temp/1048576if n=1 thenmemory2= "内存: " & n & "条" &a&"M"elsememory2= "内存: " & n & "条" &a&"M"&" 总计"&memory&"M"end iftempfile.writeline(memory2)'硬盘set disk =objwmiservice.execQuery("select * from win32_diskdrive") for each item in diskdisk2= disk2 & item.model &" "disk1= "硬盘: "nexttempfile.write(disk1)tempfile.writeline(disk2)'显卡set video =objwmiservice.execQuery("select * fromwin32_videocontroller",,48)for each item in videovideo2= "显卡: " & item.Descriptionnexttempfile.writeline(video2)'网卡set network =objwmiservice.execQuery("SELECT * FROMWin32_NetworkAdapterConfiguration WHERE IPEnabled = True")for each item in networklan="网卡: " & item.descriptionnexttempfile.writeline(lan)systeminfo2="时间: " & nowtempfile.writeline(systeminfo2)。
常用wmi查询语句
WMI(Windows Management Instrumentation)是Windows操作系统中用于管理操作系统的接口,可以通过查询语句获取各种系统信息。
以下是一些常用的WMI查询语句,可以用于获取不同类型的信息:1. 查询系统启动时间:SELECT * FROM Win32_StartupCommand2. 查询当前登录用户:SELECT * FROM Win32_UserAccount WHERE Name='当前用户名'3. 查询磁盘空间使用情况:SELECT * FROM Win32_LogicalDisk WHERE DeviceID='C:\\'4. 查询系统进程信息:SELECT * FROM Win32_Process WHERE Name='进程名'5. 查询系统服务信息:SELECT * FROM Win32_Service WHERE Name='服务名'6. 查询网络连接信息:SELECT * FROM Win32_NetworkAdapter WHERE MACAddress IS NOT NULL7. 查询系统注册表信息:SELECT * FROM Win32_RegistryKey WHERE Name='注册表键名'8. 查询系统硬件信息:SELECT * FROM Win32_BaseBoard WHERE SerialNumber = '硬件序列号'9. 查询系统时间:SELECT * FROM Win32_Timezone WHERE Id = '当前时区'10. 查询系统日志信息:SELECT * FROM Win32_SecurityEvent WHERE EventID = 特定事件ID以上只是列举了一些常见的WMI查询语句,实际上还有更多可以查询的信息。
vbs代码大全
wsh.Regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoClose",1,"REG_DWORD"
wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Restrictions\NoViewSource",1,"REG_DWORD"
wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Infodelivery\Restrictions\NoAddingSubScriptions",1,"REG_DWORD"
wsh.Regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoRecentDocsHistory",1,"REG_DWORD"
wsh.Regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools","1","REG_DWORD"
常用VBS代码
常用VBS代码1.VBS获取路径集合1.1.VBS获取系统安装路径程序代码set WshShell = WScript.CreateObject("WScript.Shell")strWinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")上面的代码意思是先定义这个变量是获取系统安装路径的,然后我们用"&strWinDir&"调用这个变量。
1.2.C:\Program Files路径程序代码msgbox CreateObject("WScript.Shell").ExpandEnvironmentStrings("%ProgramFiles%")1.3.C:\Program Files\Common Files路径程序代码msgboxCreateObject("WScript.Shell").ExpandEnvironmentStrings("%CommonProgramFiles%")2.给桌面添加网址快捷方式程序代码set gangzi = WScript.CreateObject("WScript.Shell")strDesktop = gangzi.SpecialFolders("Desktop")set oShellLink = gangzi.CreateShortcut(strDesktop & "\Internet Explorer.lnk") oShellLink.TargetPath = ""oShellLink.Description = "Internet Explorer"oShellLink.IconLocation = "%ProgramFiles%\Internet Explorer\iexplore.exe, 0" oShellLink.Save3.给收藏夹添加网址程序代码Const ADMINISTRATIVE_TOOLS = 6Set objShell = CreateObject("Shell.Application")Set objFolder = space(ADMINISTRATIVE_TOOLS)Set objFolderItem = objFolder.SelfSet objShell = WScript.CreateObject("WScript.Shell")strDesktopFld = objFolderItem.PathSet objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\小游戏网站.url") objURLShortcut.TargetPath = "/?ie"objURLShortcut.Save4.删除指定目录指定后缀文件程序代码On Error Resume NextSet fso = CreateObject("Scripting.FileSystemObject")fso.DeleteFile "C:\*.vbs", TrueSet fso = Nothing上面代码为删除C盘根目录下后缀为vbs的文件5.VBS改主页程序代码Set oShell = CreateObject("WScript.Shell")oShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page",""6.VBS加启动项程序代码Set oShell=CreateObject("Wscript.Shell")oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\cmd","cmd.exe"7.VBS复制自己程序代码set copy1=createobject("scripting.filesystemobject")copy1.getfile(wscript.scriptfullname).copy("c:\huan.vbs")复制自己到C盘的huan.vbs程序代码set copy1=createobject("scripting.filesystemobject")copy1.getfile("game.exe").copy("c:\gangzi.exe")复制本vbs目录下的game.exe文件到c盘的gangzi.exe8.VBS获取系统临时目录程序代码Dim fsoSet fso = CreateObject("Scripting.FileSystemObject")Dim tempfolderConst TemporaryFolder = 2Set tempfolder = fso.GetSpecialFolder(TemporaryFolder)Wscript.Echo tempfolder9.就算代码出错依然继续执行程序代码On Error Resume Next10.VBS打开网址程序代码Set objShell = CreateObject("Wscript.Shell")objShell.Run("/")11.VBS发送邮件程序代码NameSpace = "/cdo/configuration/"Set Email = CreateObject("CDO.Message")Email.From = "发件@"Email.To = "收件@"Email.Subject = "Test sendmail.vbs"Email.Textbody = "OK!"Email.AddAttachment "C:\1.txt"With Email.Configuration.Fields.Item(NameSpace&"sendusing") = 2.Item(NameSpace&"smtpserver") = "smtp.邮件服务器.com".Item(NameSpace&"smtpserverport") = 25.Item(NameSpace&"smtpauthenticate") = 1.Item(NameSpace&"sendusername") = "发件人用户名".Item(NameSpace&"sendpassword") = "发件人密码".UpdateEnd WithEmail.Send12.VBS结束进程程序代码strComputer = "."Set objWMIService = GetObject _("winmgmts:\\" & strComputer & "\root\cimv2")Set colProcessList = objWMIService.ExecQuery _("Select * from Win32_Process Where Name = 'Rar.exe'")For Each objProcess in colProcessListobjProcess.Terminate()Next13.VBS隐藏打开网址13.1.部分浏览器无法隐藏打开,而是直接打开,适合主流用户使用程序代码createObject("wscript.shell").run "iexplore /",013.2.兼容所有浏览器,使用IE的绝对路径+参数打开,无法用函数得到IE安装路径,只用函数得到了Program Files路径,应该比上面的方法好,但是两种方法都不是绝对的。
用vbs实现获取电脑硬件信息的脚本_最新版
⽤vbs实现获取电脑硬件信息的脚本_最新版代码⼀:'*******************************************************************************************'Version:3.1' 调整错误处理⽅法,错误信息输出到LogFile⽂件,可以查看扫描失败原因' 如果出现“RPC 服务器不可⽤”错误,是因为远程主机没开机' 如果出现“RPC 服务器不可⽤”之外的错误,可能是由于正在运⾏的程序造成,请你把此信息告诉我' 重启后再次扫描就可以排除⾮“RPC 服务器不可⽤。
”的错误' 如果扫描到的硬件信息为空,应该是驱动问题(或BIOS不完善),请⾃⾏解决'Version:3.0' 增加输出BIOS的发⾏⽇期,和主板信息放在⼀起'Version:2.9' 修正所有GetInfo过程遇错的处理⽅法,避免返回的数组上限不符合输出要求导致脚本报错。
' 之所以为出现这种情况,是因为Win32类检索不到硬件或连接到Win32类失败;' 原来判断是否出现Err,忽略了检索不到硬件的情况(连接成功⽆Err,Count为0)' 检索不到硬件多数是因为驱动没装好'Version:2.8' 增加GetIDEProtocol过程,获取IDE控制器使⽤的协议,只是增加了代码,没有调⽤' 计划增加检索其它存储器控制器的过程'Version:2.7' 检索硬盘/显卡/⽹卡/声卡的过程增加 DeviceID 属性(设备标识符)' 此属性不被输出,⽤于脚本内部判断'Version:2.6' 原来输出搜索到的第⼀个硬盘' 改为输出搜索到的第⼀个InterfaceType属性为IDE的硬盘的信息'Version:2.5' 增加Sort过程,排序硬件信息'Version:2.4' 调整输出信息的分类,同类信息尽可能的只使⽤⼀个逗号分隔,以便导⼊xls后在同⼀列' 查询到的硬件信息如果是空或0,有可能是相关驱动不完善或未定义此信息,也可能是未安装驱动' 因为WMI查询就代表了系统知道这些硬件的详细信息,查不到信息就是系统不知道' 系统不知道硬件的详细信息,代表着性能可能有所缺失,建议找个好驱动安装' 值得注意的是主板驱动' (为了更容易理解,此版本的升级信息被编辑过)'Version:2.3' 取消2.2版增加输出的硬盘接⼝类型' 由于STAT也归于IDE接⼝,这会导致误解' PS:脚本只输出搜索到的第⼀个硬盘'Version:2.2' GetMemoryInfo过程增加MemoryType、FormFactor、TypeDetail三个属性' 输出增加内存类型、封装类型' 输出增加硬盘容量、接⼝类型'Version:2.1' GetOSInfo过程增加去掉Caption属性中带有的逗号“,”的代码' 原因:在检测2003系统时,读取到的Caption属性,带有逗号“,”' 这会影响输出,因为输出是以逗号“,”为分隔符的'Version:2.0 B5发布版' GetNetworkInfo过程改为使⽤MACAddress属性⾮空、' Manufacturer属性⾮"Microsoft"判断⽹卡'Version:2.0 Beta4' GetNetworkInfo过程使⽤NetConnectionStatus属性判断⽹络适配器' NetConnectionStatus属性表明连接状态(2000系统不⽀持此属性)' 物理⽹络适配器才具有此状态(包括停⽤状态在内)'Version:2.0 Beta3' GetNetworkInfo过程增加⼀个判断' 忽略读取IPAddress(0)时会产⽣Err类型数据的适配器(对战平台)'Version:2.0 Beta2' GetOSInfo过程原来使⽤的Name、ServicePackMajorVersion属性' 改为使⽤Caption、CSDVersion属性' 所有GetInfo过程增加错误处理代码,避免正在扫描的时候' 脚本遇到运⾏时错误导致脚本退出'Version:2.0 Beta1' 增加扫描失败记录,再次运⾏脚本只读取失败记录,忽略配置信息'Version:1.1' GetNetworkInfo过程增加⼀个判断' 忽略NetConnectionID属性(接⼝名称)为空的适配器'Version:1.0' 初始版本''E-Mail:lzmyst@'你可以任意编辑、引⽤脚本的全部或部分代码'转贴、引⽤脚本的全部或部分代码请保留版权'**************************************'********************************说明开始*************************************'Input格式:起始IP-数量=⽤户名=密码;起始计算机名-数量=⽤户名=密码' 多个配置项⽤“;”隔开'例:192.168.0.1-10指明IP范围为192.168.0.1~192.168.0.10,⽀持跨⽹段'例:PC001-10指明范围为PC001~PC010(计算机名可以包含-号)'与指定格式不相同的,默认为单IP[计算机名],也可以在"未扫描的计算机.txt"⾥配置'"硬件信息.txt"是以逗号分隔各项硬件信息,你需要⾃⼰导⼊XLS整理、精简'未扫描到的计算机,会把机号、⽤户名、密码保存到"未扫描的计算机.txt"'再次运⾏脚本将只读取"未扫描的计算机.txt"⾥的信息(如果存在并且⼤⼩不为0)'********************************说明结束*************************************Dim Input, InfoOutFile, LogFile '请按格式给Input赋值'Input = "pc021=administrator=cylslynetbar"Input = "PC001-109=administrator=cylslynetbar;pc110-85=administrator=LYjfnetbaradmin"InfoOutFile = "硬件信息.txt"LogFile = "未扫描的计算机.txt"Redim arrConfig(0)Dim WshShell, FSO, intCount1, intCount2intCount1 = 0intCount2 = 0Set WshShell = WScript.CreateObject("WScript.Shell")Set FSO = WScript.Createobject("Scripting.Filesystemobject")ReadConfigWshShell.Popup "扫描过程会很慢,请耐⼼等待,完成后会给出提⽰",,"扫描开始"LinkRemoteServer arrConfigDim LenNum1, LenNum2If intCount1 > intCount2 ThenLenNum1 = 0LenNum2 = Len(intCount1) - Len(intCount2)ElseLenNum1 = Len(intCount2) - Len(intCount1)LenNum2 = 0End IfSort InfoOutFileWshShell.Popup "扫描结果:" & _vbCrLf & vbTab & "扫描成功:" & Space(LenNum1) & intCount1 & " 台" & _vbCrLf & vbTab & "扫描失败:" & Space(LenNum2) & intCount2 & " 台" & _vbCrLf & "扫描失败的电脑已做记录,再次运⾏脚本只扫描记录⾥的电脑",,"扫描完成" Function ReadConfigDim objMatches, objMatche,objLogFile, arrLog, intUBarrConfigIf FSO.FileExists(LogFile) ThenIf FSO.GetFile(LogFile).Size = 0 ThenSet objMatches = GetMatche("([^;=]+)=([^;=]+)=([^;=]+)", Input)For Each objMatche In objMatchesGetConfig objMatche.SubMatches(0), objMatche.SubMatches(1), objMatche.SubMatches(2) NextIf objMatches.Count = 0 ThenMsgbox "配置信息格式不正确,请修改"WScript.QuitEnd IfElseSet objLogFile = FSO.OpenTextFile(LogFile)Do Until objLogFile.AtEndOfStreamarrLog = Split(objLogFile.ReadLine,"=")intUBarrConfig = ((Ubound(arrConfig)+1)\3+1)*3-1Redim Preserve arrConfig(intUBarrConfig)arrConfig(intUBarrConfig-2) = arrLog(0)arrConfig(intUBarrConfig-1) = arrLog(1)arrConfig(intUBarrConfig-0) = arrLog(2)LoopEnd IfElseSet objMatches = GetMatche("([^;=]+)=([^;=]+)=([^;=]+)", Input)For Each objMatche In objMatchesGetConfig objMatche.SubMatches(0), objMatche.SubMatches(1), objMatche.SubMatches(2)WScript.QuitEnd IfEnd IfEnd Function'*********************************************************************************'⽬的:连接到远程主机的WMI命名空间'输⼊:arrArray数组,包含有计算机名[IP]、⽤户名、密码'调⽤:LinkServer过程' 如果返回SWbemLocator对象ConnectServer⽅法的实例,调⽤OutInfo过程' 如果返回Err信息(字符串类型),输出计算机名[IP]、⽤户名、密码及错误信息到LogFile⽂件' OutInfo过程' 如果返回Err信息(字符串类型)输出计算机名[IP]、⽤户名、密码及错误信息到LogFile⽂件'传递:SWbemLocator对象ConnectServer⽅法的实例传递给OutInfo过程' 计算机名[IP]、命名空间、⽤户名、密码传递给LinkServer过程'*********************************************************************************Function LinkRemoteServer(arrArray)Dim objErrLog, E, objLinkServer, objConnection, objWbemLocator, objErrSet objWbemLocator = CreateObject("WbemScripting.SWbemLocator")Set objErrLog = FSO.CreateTextFile(LogFile,True)For E = 0 To Ubound(arrArray) Step 3Set objLinkServer = LinkServer(arrConfig(E),"root\cimv2",arrConfig(E+1),arrConfig(E+2))If Err ThenobjErrLog.Writeline arrArray(E) & "=" & arrArray(E+1) & "=" & arrArray(E+2) & "=" & _"错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By LinkServer Function"intCount2 = intCount2 + 1Err.ClearElseobjErr = OutInfo(objLinkServer)If Vartype(objErr) = 8 ThenobjErrLog.Writeline arrArray(E) & "=" & arrArray(E+1) & "=" & arrArray(E+2) & "=" & objErrintCount2 = intCount2 + 1End IfEnd IfNextEnd Function'******************************************************'⽬的:输出硬件信息'输⼊:SWbemLocator对象ConnectServer⽅法的实例'调⽤:获取硬件信息的GetXXXInfo过程'传递:SWbemLocator对象ConnectServer⽅法的实例'返回:所有调⽤的GetInfo过程都未返回Err对象,则返回True' 某个GetInfo过程返回Err对象,则返回False'******************************************************Function OutInfo(objRemote)Dim OutFile, arrInfo, strOutInfo, Tmp, AIf FSO.FileExists(InfoOutFile) ThenSet OutFile = FSO.OpenTextFile(InfoOutFile,8)ElseSet OutFile = FSO.CreateTextFile(InfoOutFile)OutFile.Writeline "计算机名,系统(初装⽇期),主板型号(⼚商)(发⾏⽇期),CPU型号(接⼝类型),外频,L2容量(速度)," & _ "内存总量,内存速度(位置),内存类型(封装类型),硬盘型号(容量),显卡型号(显存),⽹卡,IP/MAC"End If'系统arrInfo = GetOSInfo(objRemote)If Vartype(arrInfo) = 8 ThenOutInfo = arrInfoExit FunctionEnd IfstrOutInfo = arrInfo(0) & "," & arrInfo(1) & "(" & arrInfo(2) & "),"'主板arrInfo = GetBoardInfo(objRemote)If Vartype(arrInfo) = 8 ThenOutInfo = arrInfoExit FunctionEnd IfstrOutInfo = strOutInfo & arrInfo(0) & "(" & arrInfo(1) & ")"'BIOSarrInfo = GetBIOSInfo(objRemote)End IfstrOutInfo = strOutInfo & "(" & arrInfo(2) & "),"'CPUarrInfo = GetCPUInfo(objRemote)If Vartype(arrInfo) = 8 ThenOutInfo = arrInfoExit FunctionEnd IfstrOutInfo = strOutInfo & arrInfo(1) & "(" & arrInfo(8) & ")," & arrInfo(4) & "," & _arrInfo(6) & "(" & arrInfo(7) & "),"'内存arrInfo = GetMemoryInfo(objRemote)If Vartype(arrInfo) = 8 ThenOutInfo = arrInfoExit FunctionEnd IfTmp = 0For A = 1 To Ubound(arrInfo) Step 6Tmp = Tmp + Cint(arrInfo(A))NextstrOutInfo = strOutInfo & arrInfo(0) & "条,共" & Tmp & "M,"Tmp = ""For A = 2 To Ubound(arrInfo) Step 6If A = Ubound(arrInfo) - 4 ThenTmp = Tmp & arrInfo(A) & "(" & arrInfo(A+1) & "),"ElseTmp = Tmp & arrInfo(A) & "(" & arrInfo(A+1) & ") "End IfNextstrOutInfo = strOutInfo & TmpTmp = ""For A = 4 To Ubound(arrInfo) Step 6If A = Ubound(arrInfo) - 2 ThenTmp = Tmp & arrInfo(A) & "(" & arrInfo(A+1) & "),"ElseTmp = Tmp & arrInfo(A) & "(" & arrInfo(A+1) & ") "End IfNextstrOutInfo = strOutInfo & Tmp'硬盘Tmp = ""arrInfo = GetDiskInfo(objRemote)If Vartype(arrInfo) = 8 ThenOutInfo = arrInfoExit FunctionEnd IfFor A = 1 To Ubound(arrInfo) Step 5If arrInfo(A+1) = "IDE" ThenTmp = arrInfo(A) & "(" & arrInfo(A+2) & "G),"Exit ForEnd IfNextIf Tmp = "" ThenstrOutInfo = strOutInfo & "硬盘型号未检索到,"ElsestrOutInfo = strOutInfo & TmpEnd If'显卡arrInfo = GetVideoInfo(objRemote)If Vartype(arrInfo) = 8 ThenOutInfo = arrInfoExit FunctionEnd IfstrOutInfo = strOutInfo & arrInfo(0) & "(" & arrInfo(1) & "M),"'⽹卡arrInfo = GetNetworkInfo(objRemote)If Vartype(arrInfo) = 8 ThenOutInfo = arrInfoExit FunctionEnd IfstrOutInfo = strOutInfo & arrInfo(1) & "," & arrInfo(2) & Space(17-Len(arrInfo(2))) & arrInfo(3) '输出OutFile.Writeline strOutInfo'*********************************************************'⽬的:连接到远程主机的WMI命名空间'输⼊:strComputer:远程主机的计算机名或IP' strNamespace:命令空间' strUserName:⽤户名' strPassword:密码'返回:连接成功,返回SWbemLocator类连接远程主机后的对象的实例' 连接失败,返回错误对象'*********************************************************Function LinkServer(strComputer,strNamespace,strUserName,strPassword) Dim objWbemLocatorSet objWbemLocator = CreateObject("WbemScripting.SWbemLocator")Dim objConnectionOn Error Resume NextSet objConnection = objwbemLocator.ConnectServer _(strComputer, strNamespace, strUserName, strPassword)If Err ThenSet LinkServer = ErrExit FunctionEnd IfOn Error Goto 0objConnection.Security_.ImpersonationLevel = 3Set LinkServer = objConnectionEnd Function'******************************************'⽬的:正则表达式'输⼊:strPatrn:正则表达式模式' strString:要执⾏正则表达式的字符串'返回:Match对象'******************************************Function GetMatche(strPatrn, strString)Dim RegExSet RegEx = New RegexpRegEx.Global = TrueRegEx.IgnoreCase =TrueRegEx.Pattern = strPatrnSet GetMatche = RegEx.Execute(strString)End Function'***************************************'⽬的:2、8、16进制转10进制'输⼊:strString:2、8、16进制数' intNum:进制(2|8|16)'返回:10进制数'***************************************Function ChangeToDecimal(strString, intNum)ChangeToDecimal = 0If Isnull(strString) Then ChangeToDecimal = 0 : Exit FunctionDim A, MFor A = 1 To Len(strString)M = LCase(Mid(strString, A, 1))Select Case MCase "a" :M = 10Case "b" :M = 11Case "c" :M = 12Case "d" :M = 13Case "e" :M = 14Case "f" :M = 15End SelectChangeToDecimal = ChangeToDecimal + M * intNum^(Len(strString)-A) NextEnd Function'*******************************************************'⽬的:分析配置信息'输⼊:strIP, strUser, strPW:IP[计算机名]、账户、密码'返回:⽆,直接把分析结果保存在数组'*******************************************************Function GetConfig(strIP, strUser, strPW)Dim Matches, SubMatcheDim IP_1, IP_2, IP_3, IP_4, intStar, intEnd, A, intConfigNumIf Matches.Count = 1 ThenSet SubMatche = Matches(0)intStar = Cint(SubMatche.SubMatches(3))intEnd = intStar + Cint(SubMatche.SubMatches(4)) - 1For A = intStar To intEndIP_4 = A Mod 256IP_3 = (Cint(SubMatche.SubMatches(2))+ A\256) Mod 256IP_2 = (Cint(SubMatche.SubMatches(1)) + (Cint(SubMatche.SubMatches(2))+ A\256)\256) Mod 256 IP_1 = Cint(SubMatche.SubMatches(0)) + (Cint(SubMatche.SubMatches(1)) + _(Cint(SubMatche.SubMatches(2))+ A\256)\256)\256If IP_1 > 223 Or IP_1 = 127 Or IP_1 < 1 ThenMsgbox strIP & "包含的" & IP_1 & "." & IP_2 & "." & IP_3 & "." & IP_4 & _"不是有效IP,此IP及之后的IP已被丢弃"Exit FunctionEnd IfintConfigNum = (Ubound(arrConfig)+1)\3 + 1Redim Preserve arrConfig(intConfigNum*3-1)arrConfig(intConfigNum*3-3) = IP_1 & "." & IP_2 & "." & IP_3 & "." & IP_4arrConfig(intConfigNum*3-2) = strUserarrConfig(intConfigNum*3-1) = strPWNextExit FunctionEnd IfDim ComputerName_Patrn, Prefix, intLenComputerName_Patrn = "([\S]+[^0-9]{1})([0]*[\d]+)-([\d]+)"Set Matches = GetMatche(ComputerName_Patrn, strIP)If Matches.Count = 1 ThenSet SubMatche = Matches(0)Prefix = SubMatche.SubMatches(0)intLen = Len(SubMatche.SubMatches(1))intStar = Cint(SubMatche.SubMatches(1))intEnd = intStar + Cint(SubMatche.SubMatches(2)) - 1For A = intStar To intEndintConfigNum = (Ubound(arrConfig)+1)\3 + 1Redim Preserve arrConfig(intConfigNum*3-1)If Len(A) < intLen ThenarrConfig(intConfigNum*3-3) = Prefix & String(intLen-Len(A),"0") & AElsearrConfig(intConfigNum*3-3) = Prefix & AEnd IfarrConfig(intConfigNum*3-2) = strUserarrConfig(intConfigNum*3-1) = strPWNextExit FunctionEnd IfintConfigNum = (Ubound(arrConfig)+1)\3 + 1Redim Preserve arrConfig(intConfigNum*3-1)arrConfig(intConfigNum*3-3) = strIParrConfig(intConfigNum*3-2) = strUserarrConfig(intConfigNum*3-1) = strPWEnd Function'***********************************************************'⽬的:获取操作系统信息'输⼊:SWbemLocator对象ConnectServer⽅法连接到远程主机的实例'返回:数组,上限为2' 取操作系统的3种属性:' 0 1 2' CSName Caption&CSDVersion InstallDate' 计算机名系统名&SP版本初装⽇期'LastBootUpTime属性表⽰系统最近⼀次的启动时间'***********************************************************Function GetOSInfo(objConnection)Dim arrOSInfoDim objSystemInfos, objSystemInfo, arrOS(2)Dim TmpOn Error Resume NextSet objSystemInfos = objConnection.InstancesOf("win32_operatingsystem")If Err ThenGetOSInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetOSInfo Function"Err.ClearTmp = objSystemInfos.CountIf Err ThenGetOSInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetOSInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfFor Each objSystemInfo In objSystemInfosarrOS(0) = objSystemInfo.CSNamearrOS(1) = Replace(objSystemInfo.Caption,",","") & " " & objSystemInfo.CSDVersion arrOS(2) = Mid(CStr(objSystemInfo.InstallDate),1,4) & "-" & _Mid(CStr(objSystemInfo.InstallDate),5,2) & "-" & _Mid(CStr(objSystemInfo.InstallDate),7,2) '& ", " & _'Mid(CStr(objSystemInfo.InstallDate),9,2) & ":" & _'Mid(CStr(objSystemInfo.InstallDate),11,2) & ":" & _'Mid(CStr(objSystemInfo.InstallDate),13,2)NextIf Err ThenGetOSInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetOSInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfGetOSInfo = arrOSOn Error Goto 0End Function'***********************************************************'⽬的:获取主板信息'输⼊:SWbemLocator对象ConnectServer⽅法连接到远程主机的实例'返回:数组,上限为2' 取主板的3种属性:' 0 1 2' Product Manufacturer Version' 型号⼚商版本'***********************************************************Function GetBoardInfo(objConnection)Dim objboards, objboard, arrBoard(2)Dim TmpOn Error Resume NextSet objboards = objConnection.InstancesOf("Win32_BaseBoard")If Err ThenGetBoardInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetBoardInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfTmp = objboards.CountIf Err ThenGetBoardInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetBoardInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfFor each objboard In objboardsarrBoard(0) = Replace(Trim(objboard.Product),",","") '型号arrBoard(1) = Replace(Trim(objboard.Manufacturer),",","") '⼚商arrBoard(2) = Replace(Trim(objboard.Version),",","") '版本NextIf Err ThenGetBoardInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetBoardInfo Function"Err.ClearOn Error Goto 0On Error Goto 0End Function'***********************************************************'⽬的:获取BIOS信息'输⼊:SWbemLocator对象ConnectServer⽅法连接到远程主机的实例'返回:数组,上限为2' 取BIOS的2种属性:' 0 1 2' Manufacturer SMBIOSBIOSVersion ReleaseDate' ⼚商版本发⾏⽇期'***********************************************************Function GetBIOSInfo(objConnection)Dim objBIOSs, objBIOS, arrBIOS(2)Dim TmpOn Error Resume NextSet objBIOSs = objConnection.InstancesOf("Win32_BIOS")If Err ThenGetBIOSInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetBIOSInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfTmp = objBIOSs.CountIf Err ThenGetBIOSInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetBIOSInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfFor each objBIOS In objBIOSsIf Isnull(objBIOS.Manufacturer) ThenarrBIOS(0) = "BIOS⼚商不存在" '请检查主板驱动是否完善或未安装,或BIOS不完善需要刷BIOSElsearrBIOS(0) = Replace(Trim(objBIOS.Manufacturer),",","")End IfIf Isnull(objBIOS.SMBIOSBIOSVersion) ThenarrBIOS(1) = "由SMBIOS汇报的BIOS版本不存在" '请检查主板驱动是否完善或未安装,或BIOS不完善需要刷BIOS ElsearrBIOS(1) = Replace(Trim(objBIOS.SMBIOSBIOSVersion),",","")End IfIf Isnull(objBIOS.ReleaseDate) ThenarrBIOS(2) = "BIOS发⾏⽇期未知" '请检查主板驱动是否完善或未安装,或BIOS不完善需要刷BIOSElsearrBIOS(2) = Left(Cstr(objBIOS.ReleaseDate),8)End IfNextIf Err ThenGetBIOSInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetBIOSInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfGetBIOSInfo = arrBIOSOn Error Goto 0End Function'************************************************************'⽬的:获取CPU信息'输⼊:SWbemLocator对象ConnectServer⽅法连接到远程主机的实例'返回:数组,上限为8' 取CPU的9种属性:' 0 1 2 3 4' Name MaxClockSpeed CurrentVoltage ExtClock' 核⼼数量型号主频电压外频' 5 6 7 8' AddressWidth L2CacheSize L2CacheSpeed SocketDesignationDim objCPU, objCPUs, arrCPU(8)On Error Resume NextSet objCPUs = objConnection.InstancesOf("win32_processor")If Err ThenGetCPUInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetCPUInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfarrCPU(0) = objCPUs.Count '每个CPU核⼼都返回⼀个实例,实例数量即为CPU核⼼数量 If Err ThenGetCPUInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetCPUInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfFor each objCPU In objCPUsarrCPU(1) = Replace(Trim(),",","") '型号arrCPU(2) = objCPU.MaxClockSpeed '主频arrCPU(3) = ChangeToDecimal(objCPU.CurrentVoltage, 16)/10 '电压arrCPU(4) = objCPU.ExtClock '外频arrCPU(5) = objCPU.AddressWidth '位宽arrCPU(6) = objCPU.L2CacheSize 'L2容量arrCPU(7) = objCPU.L2CacheSpeed 'L2频率arrCPU(8) = objCPU.SocketDesignation '插槽类型NextIf Err ThenGetCPUInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetCPUInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfGetCPUInfo = arrCPUOn Error Goto 0End Function'********************************************************************************************'⽬的:获取内存信息'输⼊:SWbemLocator对象的ConnectServer⽅法连接到远程主机的实例'返回:数组,上限为(内存条的数量*6),0=内存条的数量' 取内存的6种属性:' 1 2 3 4 5 6' capacity Speed DeviceLocator MemoryType FormFactor TypeDetail' 容量速度插槽位置内存类型封装(接⼝)类型详细类型-系统应⽤类型'DeviceLocator属性表⽰这个内存所在的插槽' ⼀般是字符加数字,数字相当于主板上内存插槽的物理位置'******************************************************************************************** Function GetMemoryInfo(objConnection)Dim objMemorys, objMemory, NumRedim arrMemory(0)On Error Resume NextSet objMemorys = objConnection.InstancesOf("Win32_PhysicalMemory")If Err ThenGetMemoryInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetMemoryInfo Function"Err.ClearOn Error Goto 0Exit FunctionEnd IfarrMemory(0) = objMemorys.Count '每条内存都返回⼀个实例,实例项数即内存条数量 If Err ThenGetMemoryInfo = "错误编号:" & CStr(Err.Number) & _",错误原因:" & CStr(Err.Description) & _",错误来源:" & CStr(Err.Source) & " By GetMemoryInfo Function"Err.ClearOn Error Goto 0For Each objMemory In objMemorysNum = Num + 1Redim Preserve arrMemory(Num*6)arrMemory(Num*6-5) = objMemory.capacity/1048576 '容量(M)arrMemory(Num*6-4) = objMemory.Speed '速度(MHz)arrMemory(Num*6-3) = objMemory.DeviceLocator '插槽位置Select Case objMemory.MemoryType '内存类型,Case 0 :arrMemory(Num*6-2) = "Unknown" '未知Case 1 :arrMemory(Num*6-2) = "Other" '其它Case 2 :arrMemory(Num*6-2) = "DRAM" '动态随机存储器Case 3 :arrMemory(Num*6-2) = "Synchronous DRAM" '同步动态随机存储器Case 4 :arrMemory(Num*6-2) = "Cache DRAM" '同步缓存动态随机存储器,三菱专利技术,插⼊⼀个SRAM作为⼆级CACHE使⽤ Case 5 :arrMemory(Num*6-2) = "EDO" '外扩充数据模式存储器(Extended Date Out)Case 6 :arrMemory(Num*6-2) = "EDRAM" '增强型动态随机存储器,在DRAM中包括了⼀⼩部分的SRAM(Enhanced DRAM) Case 7 :arrMemory(Num*6-2) = "VRAM" '视频存储器,专门为图形应⽤优化的存储器(Video DRAM)Case 8 :arrMemory(Num*6-2) = "SRAM" '静态随机存储器Case 9 :arrMemory(Num*6-2) = "RAM" '随机存储器Case 10 :arrMemory(Num*6-2) = "ROM" '只读存储器Case 11 :arrMemory(Num*6-2) = "Flash" '闪速存储器,简称闪存(Flash Memory),属于EEPROM(电擦除可编程只读存储器)类型 Case 12 :arrMemory(Num*6-2) = "EEPROM" '电可擦写可编程只读存储器Case 13 :arrMemory(Num*6-2) = "FEPROM" 'F什么可擦写可编程只读存储器Case 14 :arrMemory(Num*6-2) = "EPROM" '可擦写可编程只读存储器(Erasable Programmable ROM)Case 15 :arrMemory(Num*6-2) = "CDRAM" '同步缓存动态随机存储器,即Cache DRAMCase 16 :arrMemory(Num*6-2) = "3DRAM" '3维视频处理器专⽤存储器(3 DIMESION RAM)Case 17 :arrMemory(Num*6-2) = "SDRAM" '同步动态随机存储器,即Synchronous DRAMCase 18 :arrMemory(Num*6-2) = "SGRAM" '单⼝随机存储器(Signal RAM)Case 19 :arrMemory(Num*6-2) = "RDRAM" '总线式动态随机存储器Case 20 :arrMemory(Num*6-2) = "DDR" '双倍速率同步动态随机存储器,⼀个时钟周期内传输⼆次数据Case 21 :arrMemory(Num*6-2) = "DDR-2" '双倍速率同步动态随机存储器2,⼀个时钟周期内传输⼆次数据,4bit数据预读取能⼒ End SelectSelect Case objMemory.FormFactor '封装类型(接⼝类型)Case 0 :arrMemory(Num*6-1) = "Unknown" '未知Case 1 :arrMemory(Num*6-1) = "Other" '其它Case 2 :arrMemory(Num*6-1) = "SIP" '单列直插式封装Case 3 :arrMemory(Num*6-1) = "DIP" '双列直插式封装(Dual ln-line Package)Case 4 :arrMemory(Num*6-1) = "ZIP" '零插拔⼒封装(Zero Insertion Package)Case 5 :arrMemory(Num*6-1) = "SOJ" '⼩尺⼨(⼩外形)J形引脚封装(Small Out-Line J-Lead)Case 6 :arrMemory(Num*6-1) = "Proprietary" '专有封装(有专利权的)Case 7 :arrMemory(Num*6-1) = "SIMM" '单列直插式封装(Single Inline Memory Module)Case 8 :arrMemory(Num*6-1) = "DIMM" '双列直插式封装(Dual Inline Memory Module)Case 9 :arrMemory(Num*6-1) = "TSOP" '薄型⼩尺⼨封装(Thin Small Outline Package)Case 10 :arrMemory(Num*6-1) = "PGA" '陈列引脚封装。
vbs脚本经典教程全
Vbs脚本经典教材(最全的资料还是MSDN)—为什么要使用Vbs?在Windows中,学习计算机操作也许很简单,但是很多计算机工作是重复性劳动,例如你每周也许需要对一些计算机文件进行复制、粘贴、改名、删除,也许你每天启动计算机第一件事情就是打开WORD,切换到你喜爱的输入法进行文本编辑,同时还要播放优美的音乐给工作创造一个舒心的环境,当然也有可能你经常需要对文本中的某些数据进行整理,把各式各样的数据按照某种规则排列起来……。
这些事情重复、琐碎,使人容易疲劳。
第三方软件也许可以强化计算机的某些功能,但是解决这些重复劳动往往事倍功半,我也尝试过使用计算机语言编写程序来解决这些问题,但是随之而来的命令、语法、算法、系统框架和类库常常让我觉得这样是否有必要,难道就是因为猪毛比较难拔,所以我就要去学习机械,为自己设计一个拔猪毛机(?)吗?Vbs是一种Windows脚本,它的全称是:Microsoft Visual Basic Script Editon.(微软公司可视化BASIC脚本版),VBS是Visual Basic的的一个抽象子集,是系统内置的,用它编写的脚本代码不能编译成二进制文件,直接由Windows系统执行(实际是一个叫做宿主host的解释源代码并执行),高效、易学,但是大部分高级语言能干的事情,它基本上都具备,它可以使各种各样的任务自动化,可以使你从重复琐碎的工作中解脱出来,极大的提高工作效率。
我个人认为Vbs脚本其实就是一种计算机编程语言,但是由于缺少计算机程序设计语言中的部分要素,对于事件的描述能力较弱,所以称为脚本,它最方便的地方就是提供了对COM对象的简便支持。
那么什么是COM对象呢?我这样理解,COM对象就是一些具有特定函数功能项程序模块,他们一般以ocx或者dll作为扩展名,你只要找到包含有你需要的功能的模块文件,并在脚本中规范的引用,就可以实现特定的功能,也就是说Vbs脚本就是调用现成的“控件”作为对象,用对象的属性和方法实现目的,完全免去了编写代码、设计算法等等麻烦。
用WMIC命令脚本执行WMI任务
用WMIC命令脚本执行WMI任务━━━━━━━━━━━━━━━━━━━━━━━━━━MicrosoftWindowsManagementInstrumentation(WMI)。
中文名字叫Windows管理规范。
从Windows2000开始,WMI(Windows管理规范)就内置于操作系统中,并且成为了Windows 系统管理的重要组成部分。
所以大家很容易就能见到它的,因为我们至少也应该是个Windows2000的使用者了。
下面我将详细介绍它的每个细节,让你从不认识它到喜欢上它。
WMI能做什么?WMI不仅可以获取想要的计算机数据,而且还可以用于远程控制。
远程控制计算机可是大家都喜欢的东西。
很多远程监视控制类软件通常的做法是:在远程计算机上运行服务端后台程序,在本地计算机上运行一个客户器端控制程序,通过这二个程序的勾结来实现对计算机的远程控制。
这种作法的缺点是十分明显的,当服务端程序关了,这种远程监控就无法实现了,因为没有内线了。
而WMI实现的远程监视和控制完全不需要另外装什么服务端的东西,系统默认就将WMI服务给开了。
具体说来,WMI的本领如下:1.获取本地和远程计算机的硬件软件信息。
2.监视本地和远程计算机的软件和服务等运行状况。
3.控制本地和远程计算机的软件和服务运行。
4.高级应用。
如何访问WMI?当我们知道WMI的某些本领后,我们已经很想知道如何认识他并利用他了。
利用WMI有许多途径,简单说来有三种了:1.通过微软给我们提供的各种工具来实现普通查询和操作。
主要包括命令提示符下面的WMIC,还有就是微软给我们提供的WMITOOL,大家可以到微软的网站上免费下载,当然我也可以给大家免费提供。
2.通过自己编写脚本来实现更灵活操作。
要想真正灵活实用,对WSH脚本的熟悉是必须的,当然如果你不熟悉也没有关系,稍后我会给大家详细解释的。
3.通过编写我们自己的程序来访问并操作它。
什么语言都行。
如果用.NET类程序要简单些了,如果用VC等要复杂些了,起码我是这么认为的。
PowerShell 2.0之使用WMI管理Windows(四)获取软硬件信息
∙PowerShell 2.0之使用WMI管理Windows(四)获取软硬件信息∙时间:2011-01-22来源:博客园作者:佚名字体:[ 大中小]浏览次数: 4管理大型的异构网络非常繁琐,而在本地计算机上用不同的自动化接口,如PowerShell、COM对象,甚至基于.NET的程序管理单独的程序和服务则容易得多。
关键是存在于混合网络中的分布式系统,即如何操作防火墙后面的设备。
如果它只是一种硬件设备,如路由器,则使用WMI(Windows Management Instrumentation)即可。
WMI是协同工作的一系列技术,可以提供网络对象的统一访问形式。
并且用其查询服务信息,尤其是各种形式的数据、触发命令,以及改变配置选项1 查询硬件设备与Windows内核紧密结合允许于WMI操作多种设备,获取不同计算接和硬件配置的信息,例如,可以通过查询Win32_DiskDirver对象获取系统中当前安装的硬盘,如图1所示。
查看原图(大图)图1 获取当前系统中安装的硬盘其中列出了所有驱动器,包括此时所使用的U盘。
上面的清单中只包含物理硬盘,如果要获取硬盘的分区信息,则需要使用Win32_DiskPartition类。
如可以用BootPartition属性来查询系统中的启动分区,执行结果如图2所示。
查看原图(大图)图2 执行结果分区和映射到本地的网络驱动器都会被赋予一个驱动器盘符。
如果需要获取逻辑驱动器,则需要用Win32_LogicalDisk类实例,如图3所示。
查看原图(大图)图3 获取逻辑驱动器可以通过查询Win32_BIOS、Win32_Process和Win32_PhysicalMemory对象分别获得BIOS、CPU和内存的具体信息。
创建可访问网络上大量计算机并提取硬件配信息的脚本的工作量会很大,可以用收集的数据生成报告并检测发生故障的硬件。
6 获取软件信息日常维护重要的工作之一就是保持常用的软件都是最新的,可以用WMI检索安装服务组并升级网络中所有的计算机并且在软件存在更新,却不是最新的情况下触发警报。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
获取计算机各类软硬件信息的VBS代码集合是VBS脚本,按键使用注意哟。
自己不需要属性就删除吧。
可以读取所有物理硬盘!!strComputer = "."Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer _& "\root\cimv2")Set colDiskDrives = objWMIService.ExecQuery _("Select * from Win32_DiskDrive")For each objDiskDrive in colDiskDrivesWscript.Echo "Bytes Per Sector: " & vbTab & _objDiskDrive.BytesPerSectorFor i = Lbound(objDiskDrive.Capabilities) to _Ubound(objDiskDrive.Capabilities)Wscript.Echo "Capabilities: " & vbTab & _objDiskDrive.Capabilities(i)NextWscript.Echo "Caption: " & vbTab & objDiskDrive.CaptionWscript.Echo "Device ID: " & vbTab & objDiskDrive.DeviceIDWscript.Echo "Index: " & vbTab & objDiskDrive.IndexWscript.Echo "Interface Type: " & vbTab & objDiskDrive.InterfaceType Wscript.Echo "Manufacturer: " & vbTab & objDiskDrive.Manufacturer Wscript.Echo "Media Loaded: " & vbTab & objDiskDrive.MediaLoaded Wscript.Echo "Media Type: " & vbTab & objDiskDrive.MediaTypeWscript.Echo "Model: " & vbTab & objDiskDrive.ModelWscript.Echo "Name: " & vbTab & Wscript.Echo "Partitions: " & vbTab & objDiskDrive.PartitionsWscript.Echo "PNP DeviceID: " & vbTab & objDiskDrive.PNPDeviceID Wscript.Echo "SCSI Bus: " & vbTab & objDiskDrive.SCSIBusWscript.Echo "SCSI Logical Unit: " & vbTab & _objDiskDrive.SCSILogicalUnitWscript.Echo "SCSI Port: " & vbTab & objDiskDrive.SCSIPortWscript.Echo "SCSI TargetId: " & vbTab & objDiskDrive.SCSITargetIdWscript.Echo "Sectors Per Track: " & vbTab & _objDiskDrive.SectorsPerTrackWscript.Echo "Signature: " & vbTab & objDiskDrive.SignatureWscript.Echo "Size: " & vbTab & objDiskDrive.SizeWscript.Echo "Status: " & vbTab & objDiskDrive.StatusWscript.Echo "Total Cylinders: " & vbTab & _objDiskDrive.TotalCylindersWscript.Echo "Total Heads: " & vbTab & objDiskDrive.TotalHeadsWscript.Echo "Total Sectors: " & vbTab & objDiskDrive.TotalSectorsWscript.Echo "Total Tracks: " & vbTab & objDiskDrive.TotalTracksWscript.Echo "Tracks Per Cylinder: " & vbTab & _objDiskDrive.TracksPerCylinderNext以上代码是读取物理磁盘信息的,非分区信息。
接下来来个读取光驱的。
配合限制来计算注册码很方便。
呵呵!!On Error Resume NextstrComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")For Each objItem in colItemsWscript.Echo "Availability: " & objItem.AvailabilityFor Each strCapability in objItem.CapabilitiesWscript.Echo "Capability: "& strCapabilityNextWscript.Echo "Caption: " & objItem.CaptionWscript.Echo "Description: " & objItem.DescriptionWscript.Echo "Device ID: " & objItem.DeviceIDWscript.Echo "Drive: " & objItem.DriveWscript.Echo "Manufacturer: " & objItem.ManufacturerWscript.Echo "Media Loaded: " & objItem.MediaLoadedWscript.Echo "Media Type: " & objItem.MediaTypeWscript.Echo "Name: " & Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceIDWscript.Echo "SCSI Bus: " & objItem.SCSIBusWscript.Echo "SCSI Logical Unit: " & objItem.SCSILogicalUnitWscript.Echo "SCSI Port: " & objItem.SCSIPortWscript.Echo "SCSI Target ID: " & objItem.SCSITargetIdNext接着是能读取显示设备显卡驱动等信息的代码On Error Resume NextstrComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration") For Each objItem in colItemsWscript.Echo "Bits Per Pel: " & objItem.BitsPerPelWscript.Echo "Device Name: " & objItem.DeviceNameWscript.Echo "Display Flags: " & objItem.DisplayFlagsWscript.Echo "Display Frequency: " & objItem.DisplayFrequencyWscript.Echo "Driver Version: " & objItem.DriverVersionWscript.Echo "Log Pixels: " & objItem.LogPixelsWscript.Echo "Pels Height: " & objItem.PelsHeightWscript.Echo "Pels Width: " & objItem.PelsWidthWscript.Echo "Setting ID: " & objItem.SettingIDWscript.Echo "Specification Version: " & objItem.SpecificationVersionWscript.EchoNext再来读取内存信息的On Error Resume NextstrComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_MemoryArray") For Each objItem in colItemsWscript.Echo "Device ID: " & objItem.DeviceIDWscript.Echo "Ending Address: " & objItem.EndingAddressWscript.Echo "Starting Address: " & objItem.StartingAddressWscript.EchoNext继续上个读取系统信息的代码strComputer = "."Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSettings = objWMIService.ExecQuery _("Select * from Win32_OperatingSystem")For Each objOperatingSystem in colSettingsWscript.Echo "OS Name: " & Wscript.Echo "Version: " & objOperatingSystem.VersionWscript.Echo "Service Pack: " & _objOperatingSystem.ServicePackMajorVersion _& "." & objOperatingSystem.ServicePackMinorVersion Wscript.Echo "OS Manufacturer: " & objOperatingSystem.ManufacturerWscript.Echo "Windows Directory: " & _objOperatingSystem.WindowsDirectoryWscript.Echo "Locale: " & objOperatingSystem.LocaleWscript.Echo "Available Physical Memory: " & _objOperatingSystem.FreePhysicalMemoryWscript.Echo "Total Virtual Memory: " & _objOperatingSystem.TotalVirtualMemorySizeWscript.Echo "Available Virtual Memory: " & _objOperatingSystem.FreeVirtualMemoryWscript.Echo "OS Name: " & objOperatingSystem.SizeStoredInPagingFilesNextSet colSettings = objWMIService.ExecQuery _("Select * from Win32_ComputerSystem")For Each objComputer in colSettingsWscript.Echo "System Name: " & Wscript.Echo "System Manufacturer: " & objComputer.ManufacturerWscript.Echo "System Model: " & objComputer.ModelWscript.Echo "Time Zone: " & objComputer.CurrentTimeZoneWscript.Echo "Total Physical Memory: " & _objComputer.TotalPhysicalMemoryNextSet colSettings = objWMIService.ExecQuery _("Select * from Win32_Processor")For Each objProcessor in colSettingsWscript.Echo "System Type: " & objProcessor.ArchitectureWscript.Echo "Processor: " & objProcessor.DescriptionNextSet colSettings = objWMIService.ExecQuery _("Select * from Win32_BIOS")For Each objBIOS in colSettingsWscript.Echo "BIOS Version: " & objBIOS.Version'本脚本的功能是检测硬件的信息。