'declaració de variables globals Option Explicit Dim oShell, oNet, strUsuari, strExecuta '-------------------------------------------------------------------- Set oShell = CreateObject("Wscript.Shell") Set oNet = CreateObject("Wscript.Network") '-------------------------------------------------------------------- '---------------------- Mapeig cua Reprografia ----------------------- on error resume next strUsuari = INPUTBOX ("Identifique-vos amb el nom d'usuari de la intranet de la UPC", "Configuració impressora", "") strUsuari = strUsuari & "@repro-canon.upc.edu" If strUsuari <> "@repro-canon.upc.edu" then strExecuta = "cmdkey /add:otis.repro-canon.upc.edu /user:" & strUsuari & " /pass:reprografia" oshell.run strExecuta, 0 WScript.Sleep(2000) Err.Clear cuaRepro "\\otis.repro-canon.upc.edu", "\repro-canon" If Err.Number <> 0 then MsgBox "Usuari erroni o problemes establint la connexió" & vbcrlf & "Error: " & Err.Number ,vbExclamation,"Impossible connectar la impressora" else Msgbox "La impressora repro-canon ha sigut configurada" , vbInformation End If Else MsgBox "No s'ha pogut connectar a la cua d'impressió",vbExclamation,"Impossible connectar la impressora" End if '-------------------------------------------------------------------- Function cuaRepro(PrintServer, Printer) Dim oPrinter, PrtServer, PrtName, Prt Prt = PrintServer & Printer 'Strip backslashes from UNC names PrtServer = Left(Prt,InStr(3,Prt, "\") - 1) PrtServer = Right(Left(Prt,InStr(3,Prt, "\") - 1), Len(PrtServer) - 2) PrtName = Right(Prt, Len(Prt) - Len(PrtServer) - 3) oNet.AddWindowsPrinterConnection(PrintServer & Printer) End Function '-------------------------------------------------------------------- ' Fi de l'script '--------------------------------------------------------------------