|
本帖最后由 landfish 于 2013-3-4 15:12 编辑
以下脚本是AU3 US找来的,但是编译之后运行失败哪位高人帮忙看下。。。谢谢
$strComputer = "."
Global $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootcimv2")
Global Chr = $objWMIService.ExecQuery _
("Select * From Win32_Printer Where Network = false")
For $objPrinter in $colInstalledPrinters
$objPrinter.Delete_
Next
这段源码是从AU3美国网站找来的,以下链接可能要翻墙访问
http://www.autoitscript.com/foru ... convert#entry996550
Guys, I have used AutoIT for a long time now, although I have the task of either A. executing the .vbs script with an AutoIT application, or taking the code out of the .vbs and placing it into the actual AutoIT application. Luckly, everything the .vbs does is done within WMI. It queries all the networked printers then deletes them from the machine. Not local printers, but network printers. Here is the .vbs code. How can I script this code to execute within the AutoIT application instead of launching the .vbs file?
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where Network = True")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
·········
Luckily VBScript and AutoIt are very similar, there's very little conversion required.
[ autoit ] popup
$strComputer = "."
Global $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootcimv2")
Global $colInstalledPrinters = $objWMIService.ExecQuery _
("Select * From Win32_Printer Where Network = True")
For $objPrinter in $colInstalledPrinters
$objPrinter.Delete_
Next |
|