Map printer via 'net use' batch file
I need to create a batch file that maps IP domain printers to a laptop that is not part of the domain. The user will connect via VPN and then hit this batch file on their desktop. I know I'll have to pass credentials with the net use command (I'll deal with encrypting later) for now I'm just trying to get it to work - period. I don't need it to emulate an LPT1 port for old programs or anything like that - just map IP printers to the computer. Assume that the laptop already has all of the necessary drivers. Any ideas on how to get this going? I'm finding conflicting info on the www... TIA!
April 9th, 2012 1:34pm

1. Perhaps you can add password and user name in the same way like in the case of folder share ..... psswd /user:FQDN\user_name 2. Scripting from cmd http://technet.microsoft.com/en-us/library/ee624057%28WS.10%29.aspx RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /n\\PrintServer\PrintShare 3. Powershell $prnt = [wmiclass]"Win32_Printer" $prnt.AddPrinterConnection("\\PrintServer\PrintShare") For detailes on user authentication in Poweshell ask in http://social.technet.microsoft.com/Forums/cs-CZ/winserverpowershell/threads Regards Milos
Free Windows Admin Tool Kit Click here and download it now
April 9th, 2012 3:03pm

Yes, I tried adding credentials to the net use command. It reports 'the command has completed successfully' but the printer does not show up in my devices and printers list. I'd like to get it going using 'net use' unless it's definitely not possible (web info on this is conflicting with none actually saying it CAN'T be done).
April 9th, 2012 4:37pm

I think I'm just going to use vbs. For those also looking for a way to do this - Option Explicit Dim objNetwork Dim strUser, strPassword, strUNCPrinter strUNCPrinter = "\\server\printer" strUser = "domain\user" strPassword = "password" Set objNetwork = WScript.CreateObject("WScript.Network") objNetwork.AddWindowsPrinterConnection strUNCPrinter, strUser, strPassword WScript.Quit Write it up in notepad and save it as filename.vbs and you're good to go. As an added bonus you can use the Windows script encoder to turn it into a .vbe file. THE RESULTING FILE CAN STILL BE EASILY DECODED AND VIEWED, but at least it stops prying eyes from opening the file up directly and viewing passwords.
Free Windows Admin Tool Kit Click here and download it now
April 9th, 2012 6:26pm

Hi, As you are trying to write the VB scripts, it is recommended to post your question on the Official Scripting Guys Forum for further discussion. The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding. Regards, Sabrina TechNet Subscriber Support If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.Sabrina TechNet Community Support
April 10th, 2012 12:41am

Thanks Sabrina, it started off as a 'net use' batch file. I just posted my .vbs solution here for anyone else searching for the same answer. I will post in the scripting forum if I have any further questions.
Free Windows Admin Tool Kit Click here and download it now
April 10th, 2012 1:55pm

Hi Alceryes, Thank you for your sharing which will direct other communities who encounter the similar issue. Regards, Sabrina TechNet Subscriber Support If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.Sabrina TechNet Community Support
April 10th, 2012 10:48pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics