找回密码
 加入
搜索
查看: 3986|回复: 7

[系统综合] AU3 删除本地打印机

  [复制链接]
发表于 2013-3-3 19:58:57 | 显示全部楼层 |阅读模式
本帖最后由 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
发表于 2013-3-3 21:08:56 | 显示全部楼层
Where Network = fales
应该是false吧

还有delete后面的下划线是干嘛的
 楼主| 发表于 2013-3-3 21:42:00 | 显示全部楼层
delete_谷歌了一下,虽然不知道下划线用途但是很多代码都这么写
发表于 2013-3-3 22:22:22 | 显示全部楼层
学习学习。。。。。搞不懂
发表于 2013-3-4 08:26:11 | 显示全部楼层
我感觉好像是语法上的错误,但是具体哪里不清楚
发表于 2013-3-4 08:42:49 | 显示全部楼层
学习学习。。。。。
 楼主| 发表于 2013-3-5 17:01:18 | 显示全部楼层
等高人作答~~
发表于 2013-3-5 19:29:01 | 显示全部楼层
有点复杂 看得不是很明白
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-25 21:58 , Processed in 0.079183 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表