JSI Tip 1410. How can I automate DOS default network printer assignment in a logon script?

Jerold Schulman

June 20, 1999

1 Min Read
ITPro Today logo in a gray background | ITPro Today


To use a network printer in a DOS program, you must issue a:

NET USE LPTx: \ComputerNamePrinterShare.

In tip 0672, we learned that the default printer information is located at:

HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindowsDevice

Using REGFree, we can add either of the following to a logon script:

for /f "Tokens=1-5 Delims=,: " %%i in ('reg -listvalue "HKCUSoftwareMicrosoftWindows NTCurrentVersionWindowsDevice"') do set prt=%%j&set port=%%lnet use %port%: %prt%

               OR

for /f "Tokens=2 Delims=, " %%i in ('reg -listvalue "HKCUSoftwareMicrosoftWindows NTCurrentVersionWindowsDevice"') do set prt=%%inet use LPT1: %prt%



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like