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");
}
}
}
安装打印机,但需要几秒钟才能安装打印机,并且没有通知或警告。
我的警报用户界面永远不会出现。