Hi,
I have just started with VBScript, and I'm trying to make a simple portal for printer installation. The problem is that we have a setup with different printservers, with printers with some standard names. So the HTA lets you choose where you sit, and then installs the correct printers, from the server near you.
What am i doing wrong?
<html><head><title>Printer Installation</title><script language="VBScript">
Window.ReSizeTo 350, 125
Function InstPrt(strPrtSrv)
strPrtSrvName = "Print-Server-" & strPrtSrv
strPrtShrNmAA = "\\" & strPrtSrvName & "\PrinterAA"
strPrtShrNmBB = "\\" & strPrtSrvName & "\PrinterBB"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where ShareName = 'PrinterAA' or ShareName = 'PrinterBB' and not ServerName = strPrtSrvName")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
Set WshNetwork = CreateObject("Wscript.Network")
PrinterPath = strPrtShrNmAA
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver
PrinterPath = strPrtShrNmBB
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver
WshNetwork.SetDefaultPrinter strPrtShrNmBB
Self.Close
End Function
</script></head><center><a href="#" onClick="InstPrt(a01)">Install PrinterAA & BB from Server A01</a><br><a href="#" onClick="InstPrt(b01)">Install PrinterAA & BB from Server B01</a><br><a href="#" onClick="InstPrt(c02)">Install PrinterAA & BB from Server C01</a><br></center></script></html>