HTA确定是否安装了打印机并通知用户

时间:2017-01-17 20:21:10

标签: jscript hta

    console.log(newPrinter);
    alert("Installing New Printer");
    var WshNetwork = new ActiveXObject("WScript.Network");
    var PrinterPath = "\\\\Server\\Printer";
    WshNetwork.AddWindowsPrinterConnection(PrinterPath);
    WshNetwork.SetDefaultPrinter(PrinterPath);      
    var isInstalled = false;
    while(isInstalled = false)
    {
        var oPrinters = WshNetwork.EnumPrinterConnections();
        for(i = 0; i < oPrinters.length; i += 2) {
            alert("Port " + oPrinters.Item(i) + " = " + oPrinters.Item(i + 1));
            if(PrinterPath == oPrinters.Item(i))
            {
                isInstalled = true;
                alert("Finished Installing Printer");
            }
        }
    }

安装打印机,但需要几秒钟才能安装打印机,并且没有通知或警告。

我的警报用户界面永远不会出现。

0 个答案:

没有答案