求助!如何用VBS脚本实现更改打印机默认纸张格式!!!

leonfox 2006-12-05 12:20:53
我刚刚学习脚本语言,现在遇见以下问题,请各位高手救急!

我想通过VBS脚本更改打印机的默认纸张格式:现初步编码如下:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_PrinterConfiguration where Name = 'Epson LQ-1600K'")
For Each objPrinter in colInstalledPrinters
Wscript.Echo "Name: " & objPrinter.Name
Wscript.Echo "Paper Length: " & objPrinter.PaperLength
Wscript.Echo "Paper Width: " & objPrinter.PaperWidth

objPrinter.Name = "Epson LQ-1600K1"
objPrinter.PaperLength = 2970
objPrinter.PaperWidth = 2100

Wscript.Echo "Name: " & objPrinter.Name
Wscript.Echo "Paper Length: " & objPrinter.PaperLength
Wscript.Echo "Paper Width: " & objPrinter.PaperWidth
Next

但这样写设置不能保存!
想使用 objPrinter.Put_ 命令保存信息却提示:SWbemObjectEx: 提供程序无法执行该操作
请各位帮帮忙!急!
leonfox@126.com
...全文
520 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
feillex 2006-12-05
  • 打赏
  • 举报
回复
wmi的类Win32_PrinterConfiguration 是只读,不支持更新的方法,你强制写入当然要出错。
要相对打印机进行操作用Win32_Printer类的renameprinter等方法。
具体用法查msdn
Win32_Printer
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printer.asp
leonfox 2006-12-05
  • 打赏
  • 举报
回复
很着急,请各位高手多多帮忙!

没把握不要紧,大家发上来一起讨论讨论嘛
leonfox 2006-12-05
  • 打赏
  • 举报
回复
感谢您的回复,我研究一下,谢谢。

6,849

社区成员

发帖
与我相关
我的任务
社区描述
Windows 2016/2012/2008/2003/2000/NT
社区管理员
  • Windows Server社区
  • qishine
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧