AU3 删除本地打印机
本帖最后由 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/forum/topic/141656-convert-vbs-that-utilizes-wmi-into-an-autoit-script/page__hl__+vbs%20+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 Where Network = fales
应该是false吧
还有delete后面的下划线是干嘛的 delete_谷歌了一下,虽然不知道下划线用途但是很多代码都这么写 学习学习。。。。。搞不懂 我感觉好像是语法上的错误,但是具体哪里不清楚 学习学习。。。。。 等高人作答~~ 有点复杂 看得不是很明白
页:
[1]