本帖最后由 作者 于 2007-8-9 2:04:26 编辑
欢迎fsxm一起探讨。先补几个实例 ;检索计算机上安装的光驱: (setq str " ret = \"\" strComputer = \".\" Set objSWbemLocator = CreateObject(\"WbemScripting.SWbemLocator\") Set objSWbemServices = objSWbemLocator.ConnectServer Set colItems = objSWbemServices.ExecQuery(\"Select * from Win32_CDROMDrive\") For Each objItem in colItems ret = ret & \"光盘驱动器的类型: \" & objItem.Caption & vblf ret = ret & \"盘符是: \" & objItem.Id Next msgbox ret") (xxvbs str "ret") ;-> "光盘驱动器的类型: SAMSUNG CDRW/DVD SM-332F\n盘符是: K:光盘驱动器的类型: AXV CD/DVD-ROM SCSI CdRom Device\n盘符是: L:" ;; 获得CPU的序列号。 (setq str " Set objSWbemObject = GetObject(\"winmgmts:Win32_Processor.DeviceID='cpu0'\") ret = objSWbemObject.ProcessorId msgbox \"首枚CPU序列号:\" & ret ") (xxvbs str "ret") ;;使用 WMI 和 VBScript 检索操作系统信息 (setq str " strComputer = \".\" Set objWMIService = GetObject(\"winmgmts:\\\\\" & strComputer) Set colOperatingSystems = objWMIService.InstancesOf(\"Win32_OperatingSystem\") For Each objOperatingSystem In colOperatingSystems msgbox \"Name: \" & objOperatingSystem.Name & vbCrLf & \"Caption: \" & objOperatingSystem.Caption & vbCrLf & \"CurrentTimeZone: \" & objOperatingSystem.CurrentTimeZone & vbCrLf & \"LastBootUpTime: \" & objOperatingSystem.LastBootUpTime & vbCrLf & \"LocalDateTime: \" & objOperatingSystem.LocalDateTime & vbCrLf & \"Locale: \" & objOperatingSystem.Locale & vbCrLf & \"Manufacturer: \" & objOperatingSystem.Manufacturer & vbCrLf & \"OSType: \" & objOperatingSystem. OSType & vbCrLf & \"Version: \" & objOperatingSystem.Version & vbCrLf & \"Service Pack: \" & objOperatingSystem.ServicePackMajorVersion & \".\" & objOperatingSystem.ServicePackMinorVersion & vbCrLf & \"Windows Directory: \" & objOperatingSystem.WindowsDirectory Next ") (xxvbs str "") ;;使用 WMI 和 VBScript 检索在 root\cimv2 命名空间中注册的 Win32 提供程序 (setq str "strComputer = \".\" ret = \"\" Set objWMIService = GetObject(\"winmgmts:\\\\\" & strComputer & \"\\root\\cimv2\") Set colWin32Providers = objWMIService.InstancesOf(\"__Win32Provider\") For Each objWin32Provider In colWin32Providers ret = ret & objWin32Provider.Name & vblf Next msgbox ret") (xxvbs str "ret") ;;很多GUI工具(比如流光)启动时,有一个logo页,显示版权等信息。我们用ie对象也可以模拟一个出来 (defun c:logo() (setq str " set wscript = createobject(\"wscript.shell\") set ie = wscript.createobject(\"internetexplorer.application\") ie.fullscreen = 1 ie.width = 300 ie.height = 150 ie.navigate \"about\"&\":blank\" ie.left = fix((ie.document.parentwindow.screen.availwidth-ie.width)/2) ie.top = fix((ie.document.parentwindow.screen.availheight-ie.height)/2) str = \"<body bgcolor = skyblue scroll = no><br><br>\"&\"<h2 align = center>这是一个Logo</h2></body>\" str = & str & ie.document.write ie.visible = 1 wscript.sleep 5000 ie.quit ") (xxvbs str "ret")) ;;在ie调用系统颜色选择对话 (setq str "set ie = createobject(\"internetexplorer.application\") set wscript = createobject(\"wscript.shell\") ie.navigate \"about:blank\" do until ie.readystate = 4 : wscript.sleep 25 : loop set doc = ie.document set body = doc.body set win = doc.parentwindow body.innerhtml = \"<OBJECT id=dlg CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b'></OBJECT>\" body.innertext = doc.getElementById(\"dlg\").choosecolordlg win.clipboarddata.setdata \"text\", body.innertext ie.quit ") (xxvbs str "ret") |