VBS:在没有打印服务器的情况下使用 WSHNetwork.SetDefaultPrinter
我正在尝试创建一个简单的VBS 登录脚本,为通过终端服务器环境登录到Server 2003 的用户设置默认打印机。该打印机是不通过打印服务器的网络打印机。它的 DNS 名称是“Front MailRoom Printer”,端口是 \192.168.0.82。
我的脚本是这样的:
Set WSHNetwork = CreateObject("WScript.Network")
WSHNetwork.SetDefaultPrinter "Front MailRoom Printer"
当它运行时,出现错误80070002(系统找不到指定的文件)指向第2行字符1。欢迎任何想法。
I'm trying to create a simple VBS logon script that sets the default printer for users logging into Server 2003 through a terminal server environment. The printer is a network printer that is not going through a print server. It's DNS name is "Front MailRoom Printer" and port is \192.168.0.82.
The script I have is this:
Set WSHNetwork = CreateObject("WScript.Network")
WSHNetwork.SetDefaultPrinter "Front MailRoom Printer"
When it runs, an error 80070002 (the system cannot find the file specified) points to line 2 character 1 comes up. Any ideas are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是影响打印机的用户配置文件问题,而不是代码本身的问题。如果有人关心的话,该用户不存在此注册表项:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
一旦添加它并且用户注销并重新登录,根本问题就是已解决并且脚本成功运行。
This was a user profile issue that impacted printers, not an issue with the code itself. If anyone cares, this registry key didn't exist for the user:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
Once it was added added and user logged off and back on, the root issue was resolved and script ran successfully.