maping network printer via script

  • Thread starter Thread starter Alan Gavel
  • Start date Start date
A

Alan Gavel

I have read several contributions on topic maping network printers by
scripts. The only one problem remained. How to add the username/password
into such a script?
My network department has several computers and we don't use central
server services. The printer is shared via "microsoft files and
printers sharing". The host computer has Windows XP but unfortunatelly
there are some Windows 2000 clients. They can't login to the host at
startup and everyday connecting with login/password is annoying. Each
station user has different login/password which differs from login
password for sharing network resources on host computer. I don't want to
make so many user account on host computer. Then, Is it easier to make
connection from client stations with net use syntax or might I use the
scripting host language? Could you be so kind and help me with
incorporating username/password into script or net syntax?

I have already found one script. If it is suitable for my situation
please add the username/password section.
--------------
Script start ->

On Error Resume next

Set WshNetwork = Createobject ("wscript.network")
Set WshShell = CreateObject("WScript.Shell")

PC = UCase(WshShell.ExpandEnvironmentStrings("%computername%"))

Select Case PC
Case "PRC1"
WshNetwork.addprinterconnection "lpt1", "\\printer1"
WScript.Echo "Mapped to printer printer1"
Case "PC2"
'Etc
End select

<- Script end
 
Back
Top