|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
adding printer depending on usernameHello,
I want to add a printer on the WS through a script according to the machinename on wich the user logs on. ex. if user logs on to WS A06-12 I want to install printer A06 if user logs on to WS B01-15 I want to install printer B01 if user logs on to WS B03-34 I want to install printer B03 Is this possible through a logonscript and how. Where can i find a list of the builtin variables (%username%) that i can use in a script regards, N.
Show quote
Hide quote
"nico" <nospam@hotmail.com> wrote in message A VBScript logon script can use the wshNetwork object to retrieve the name news:eWniata1JHA.4632@TK2MSFTNGP02.phx.gbl... > Hello, > > I want to add a printer on the WS through a script according to the > machinename on wich the user logs on. > > ex. if user logs on to WS A06-12 I want to install printer A06 > if user logs on to WS B01-15 I want to install printer B01 > if user logs on to WS B03-34 I want to install printer B03 > > Is this possible through a logonscript and how. > Where can i find a list of the builtin variables (%username%) that i can > use in a script > > regards, > N. > of the user and computer, then connect to the appropriate printer. For example: ======== Option Explicit Dim objNetwork, strUserName, strComputer ' Retrieve user and computer names. Set objNetwork = CreateObject("Wscript.Network") strUserName = objNetwork.UserName strComputer = objNetwork.ComputerName ' Map printer based on computer name. Select Case strComputer Case "A06-12" objNetwork.AddWindowsPrinterConnection "\\PrintServer\A06" Case "B01-15" objNetwork.AddWindowsPrinterConnection "\\PrintServer\B01" Case "B03-34" objNetwork.AddWindowsPrinterConnection "\\PrintServer\B03" End Select ====== If you want to parse the computer name to determine the printer you can use code similar to below: ======== Option Explicit Dim objNetwork, strUserName, strComputer, strPrinter ' Retrieve user and computer names. Set objNetwork = CreateObject("Wscript.Network") strUserName = objNetwork.UserName strComputer = objNetwork.ComputerName ' Use left three characters of computer name ' to identify the printer. strPrinter = Left(strComputer, 3) objNetwork.AddWindowsPrinterConnection "\\PrintServer\" & strPrinter Richard Mueller [MVP] schreef:
Show quoteHide quote > "nico" <nospam@hotmail.com> wrote in message thank you very much!> news:eWniata1JHA.4632@TK2MSFTNGP02.phx.gbl... >> Hello, >> >> I want to add a printer on the WS through a script according to the >> machinename on wich the user logs on. >> >> ex. if user logs on to WS A06-12 I want to install printer A06 >> if user logs on to WS B01-15 I want to install printer B01 >> if user logs on to WS B03-34 I want to install printer B03 >> >> Is this possible through a logonscript and how. >> Where can i find a list of the builtin variables (%username%) that i can >> use in a script >> >> regards, >> N. >> > > A VBScript logon script can use the wshNetwork object to retrieve the name > of the user and computer, then connect to the appropriate printer. For > example: > ======== > Option Explicit > Dim objNetwork, strUserName, strComputer > > ' Retrieve user and computer names. > Set objNetwork = CreateObject("Wscript.Network") > strUserName = objNetwork.UserName > strComputer = objNetwork.ComputerName > > ' Map printer based on computer name. > Select Case strComputer > Case "A06-12" > objNetwork.AddWindowsPrinterConnection "\\PrintServer\A06" > Case "B01-15" > objNetwork.AddWindowsPrinterConnection "\\PrintServer\B01" > Case "B03-34" > objNetwork.AddWindowsPrinterConnection "\\PrintServer\B03" > End Select > ====== > If you want to parse the computer name to determine the printer you can use > code similar to below: > ======== > Option Explicit > Dim objNetwork, strUserName, strComputer, strPrinter > > ' Retrieve user and computer names. > Set objNetwork = CreateObject("Wscript.Network") > strUserName = objNetwork.UserName > strComputer = objNetwork.ComputerName > > ' Use left three characters of computer name > ' to identify the printer. > strPrinter = Left(strComputer, 3) > > objNetwork.AddWindowsPrinterConnection "\\PrintServer\" & strPrinter > great stuff, N.
Stop windows service copy data and then start service
How to pass parameter from a file (txt/dll) to vbs code ANN: EditVar/EditV32/EditV64 and Choose/Choose32/Choose64 v2.0 batch file to split multiple text files in half. Set Local Computer Description Use VBScript to Set Local Computer Description Inventory script question How do implement this wildcard? Logon script help Get computer name as variable to use in vbs script. |
|||||||||||||||||||||||