Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


October 15, 2001

How can I map the default printer to LPT1 from the command line?

RSS
Subscribe to Windows IT Pro | See More Printing Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

A. Reader Daniel Wolf sent in the following Kixtart script that maps the current user's default printer to LPT1 (assuming the default printer is a network printer). To run the script, go to the command line and type

  kix32.exe printer.scr  
Kixtart is part of the Windows 2000 Server Resource Kit, Win2K Pro Resource Kit, Windows NT 4.0 Server Resource Kit, and NT 4.0 Workstation Resource Kit.

  --- printer.scr start (Kix Script) ---

   ; read Default Printer Server and Sharename from Windows Registry
   ; and map to LPT1 (Windows 2000 and Windows NT only; not tested on
   ; Windows XP)

   ; by Daniel Wolf
   ; daniel.wolf@dawolf.com

   $Printer = READVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device");

   $Index = 1

   WHILE $Index < LEN($Printer)

   $Testchar = SUBSTR($Printer, $Index, 1)
   IF $Testchar = ','
           $Cutat = $Index - 1
           $Index = LEN($Printer)
   ENDIF

   $Index = $Index + 1

   LOOP

   $Printer = SUBSTR($Printer, 1, $Cutat)
   $Checklocal = SUBSTR($Printer, 1, 2)

   ? "Default Printer: $Printer"

   ; only map if Default Printer is Network Printer
   IF $Checklocal = "\\"
           ? "Removing existing LPT1 mapping ..."
           USE LPT1 /D
           USE LPT1 $Printer
                   IF @ERROR
                           BEEP
                           ? "Error @ERROR mapping $Printer to LPT1"
                   ELSE
                           ? "Done. $Printer mapped to LPT1"
                   ENDIF
   ELSE
           ? "ABORT. Default Printer is not a network printer!"
   ENDIF

   --- printer.scr end --- 

End of Article



Reader Comments
If you are using a lower version of Windows like Win98/ME then use the following command to redirect to the LPT1 port

==========================================================================

C:\>NET USE LPT1 \\SERVER\PRINTER_NAME
The command was completed successfully

===================================

Regards


H M Sheriff December 12, 2003


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

How can I stop and start services from the command line?

...

Microsoft Touts Xbox 360 'Black Friday' Success

Microsoft this week revealed that its Xbox 360 video game console outsold its Sony PlayStation 3 rival 3-to-1 on "Black Friday," which curiously describes the three day weekend after Thanksgiving, a period that unofficially kicks off the holiday selling ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing