Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer Script with Password

Status
Not open for further replies.

VicRattlehead

Technical User
Mar 3, 2005
8
IE
Hey guys,sorry if this is in the wrong bord.
I have a script that logs me on from My laptop to my colleges(domain) printer!Now the Admin has address the need for user name and password to this printer,Ive been given a user name and password to access to the printer and wondering How id add the user name and password to that script.
Please find below a compy of My script so far

Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\rockapplication\printerroome"
WshNetwork.AddWindowsPrinterConnection PrinterPath
WScript.quit
 
Instead of using WshNetwork.AddWindowsPrinterConnection
you could use:

WshNetwork.AddPrinterConnection strLocalName, strRemoteName[,bUpdateProfile][,strUser][,strPassword]

example:
WshNetwork.AddPrinterConnection "LPT1", "\\Server\Print1", False, MyUserID, MyPassword



--------------------------------------
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
 
some explaining:

Using this method (AddWindowsPrinterConnection) is the same as using the Control Panel/Printers to add a printer connection. Unlike the AddPrinterConnection method, this method allows you to create a printer connection without directing it to a specific port such as LPT1. If the connection fails, an error occurs.
In Windows 95/98 the printer driver must already be installed on the machine in order for the AddWindowsPrinterConnection method to work. If the driver is not installed Windows will return the error message "Unknown printer driver".

The AddPrinterConnection method is the same as mapping a printer in DOS.

Hope this helps...

--------------------------------------
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
 
so in other words the script should look like this

Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.AddPrinterConnection "LPT1", "\\rockapplication\printerroome", False, UserID, PassWord
WScript.quit
 
If 'Printerroome' is the name of the printer,
and UserID and Password are variables.
Then it should work...

--------------------------------------
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
 
Thanks for help but it doesnt seem to work :(
The only concern about the above code I have is that,Im not directly connected to this printer,Im connecting in one room printers in another,I can manually connect to the printer but it takes ages thats why script is easier plus I want to b able to do this for further reference thanks KOB3
 
untitled.JPG


Thats the error Im getting,Now just to clarify something I only found out!!the Printer ITSELF isnt passworded!!Its actually My loginID and PassWord when I access the Domain,so If I log on using one of the colleges printers,its THAT ID&PASSWORD NOT ONE on the printer itself!
Thanks for all your help K0b3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top