In my last post I have explained how to use network resources by running cmd and calling NET USE command. Now I will wrote a bit more on that topic.
|net use command|
In case you need to map Network printer and use it as your local LPT Printer Device simply start cmd and run NET USE command. This is handy trick to make your MS DOS application print on a Network or USB Printer device. Many MS DOS applications can’t work with Network or USB Printers so you may need to do a little trick to make them printing.
If you are using Windows 7 and you have USB printer installed to make that Printer device work like it is connected on a LPT2 port do command as it is shown below
net use lpt2: \\mypc\printername
confirm with Enter. Code above shows how to map shared USB Printer ‘printername’ to work like LPT2 printer on a local ‘mypc’ Computer. To make your local attached USB Printer work like this first you need to Share that Device and to use his Share Name.
To make that connection permanent even after System reboot start this command
net use lpt2: \\mypc\printername /persistent:yes
and confirm with Enter. With this command your Network connection should stay after system reboot. Another way to keep your Network Printer alive is to write this command in a *.bat file. I use this method to keep my Printer accessible on each time my Application starts.
If you don’t need Network Printer anymore or it is changed and you want to make a new connection do it like it is shown
net use lpt2: /delete
confirm with Enter. This command will remove Network resource you made before. Now you don’t have LPT2 port and you can make a new connection.
Notice: These commands works with Windows XP and other MS Operating Systems. While using NET USE command keep in mind to avoid possible conflicts like to use LPT1 while that port is already in use. When you are giving your Printer his Share Name make it short up to 8 characters (letters and numbers) and without blank spaces or special characters. Sometimes it is good to protect Shared printer with a Password in which case user will be prompted to enter Username and Password. When you make Network Connection with a printer on another Computer – it will not be shown under Devices and Printers unless you install it by Install Wizard. When you are using Windows 7 make sure to start cmd as Administrator.