如果我正在做的事情完全错误或解决方案是显而易见的,请不要感到惊讶.
<script type="text/vbscript">
Function AddPrinter()
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\a2031slhsfile1\2031CAT-T113-HP4014dn"
objNetwork.SetDefaultPrinter "\\a2031slhsfile1\2031CAT-T113-HP4014dn"
MsgBox "The printer was added and set as the default printer."
End Function
</script>
Run Code Online (Sandbox Code Playgroud)
我将上面的vbscript添加到head部分的HTML文档中,其中一个按钮具有以下属性:
onclick="AddPrinter()"
Run Code Online (Sandbox Code Playgroud)
在Google上搜索一小时后,我对此并没有太多了解.我发现的东西不起作用.它是如何知道你是从javascript还是vbscript调用函数还是其他什么?
我收到此错误:
SCRIPT429: ActiveX component can't create object: 'WScript.Network'
Run Code Online (Sandbox Code Playgroud)