"net use lpt1" command not working properly in WXP


Recommended Posts

We are in an NT/2000 Server and XP Client environment. We are running a DOS application that needs to print to the lpt port. We have used the following batch file in the past:

net use lpt1 /delete

net use lpt1 \\server\printer

The print server is a 2000 box. All users can use the network printer through windows.

When the batch file is run by Normal Users or Power Users, it pauses asking for a password. We can not figure out what password it wants. When it is run by an Administrator, it runs correctly and does not ask for a password.

This command works fine on any Windows 2000 or Windows NT4 machine, but when I try it on a freshly built Windows XP machine it does not work. Any idea's?

I found this on another forum:

".....the problem is that non-administrators cannot remap an LPT port to a network printer according to Microsoft?

Now, everyone that has the same problem must download ?DEVCON.EXE? file from Microsoft?s site. Do it and copy it somewhere (?C:\? would be just fine).

Log in locally (to the box, NOT the network) as an administrator or person with administrator?s privileges.

Then you must create a batch file with the following command:

C:\Devcon disable *PNP0401

Then you must go to Start-Run and type GPEDIT.MSC. This gives you access to the group policy section. Finally, you must go to Computer Configuration\Windows Settings\Scripts(Startup/Shutdown)\Startup and add the specific script (browse the batch you have created)."

Or an easier work around, might be to map it to an unused lpt port, say 2 or 3

This from the MS article on the issue;

If your program can print to the LPT2 port or the LPT3 port, use the net use command to map the network printer to the LPT2 port or the LPT3 port. Most computers do not have physical LPT2 or LPT3 ports, so a non-administrator can map an LPT2 port or an LPT3 port to a network printer.

http://support.microsoft.com/kb/313644

even easier is to go to device manager and check under ports..then ECP...DISABLE it...that's as long as you don't have local printer attached...then that'll free up LPT1 to print to....that's all is....

...problem with the above is that MOST if not ALL DOS based program can ONLY print to LPT1...

  BudMan said:
how would going to every machine and disabling their local lpt port be easier than changing their script to "net use lpt3 \\server\printer" ? ;)

584857948[/snapback]

It won't be easier. But the bigger problem is what if the DOS program will ONLY print to LPT1?

  Mysterio said:
I found this on another forum:

".....the problem is that non-administrators cannot remap an LPT port to a network printer according to Microsoft?

Now, everyone that has the same problem must download ?DEVCON.EXE? file from Microsoft?s site. Do it and copy it somewhere (?C:\? would be just fine).

Log in locally (to the box, NOT the network) as an administrator or person with administrator?s privileges.

Then you must create a batch file with the following command:

C:\Devcon disable *PNP0401

Then you must go to Start-Run and type GPEDIT.MSC. This gives you access to the group policy section. Finally, you must go to Computer Configuration\Windows Settings\Scripts(Startup/Shutdown)\Startup and add the specific script (browse the batch you have created)."

584857689[/snapback]

My technician tried using the Devcon before with no luck, but he didn't go into Group Policy to change anything. What does he need to change?

  BudMan said:
Or an easier work around, might be to map it to an unused lpt port, say 2 or 3

This from the MS article on the issue;

If your program can print to the LPT2 port or the LPT3 port, use the net use command to map the network printer to the LPT2 port or the LPT3 port. Most computers do not have physical LPT2 or LPT3 ports, so a non-administrator can map an LPT2 port or an LPT3 port to a network printer.

http://support.microsoft.com/kb/313644

584857716[/snapback]

I will contact the maker of the program and see if this is possible. This is the first Windows XP Machine we have put out on the floor that hasn't been for a admin.

  Mysterio said:
even easier is to go to device manager and check under ports..then ECP...DISABLE it...that's as long as you don't have local printer attached...then that'll free up LPT1 to print to....that's all is....

...problem with the above is that MOST if not ALL DOS based program can ONLY print to LPT1...

584857934[/snapback]

That is what he did for a workaround for now, but I don't like this solution. It works, but I do not want to have to do that for every machine. We also have a few users who need to have a printer plugged in locally, but switch to a network printer to print from the dos programs.

Thanks for all of the advise, I hope the program can allow the use of LPT2 or 3.

  Mysterio said:
if they gotta a #@$@$ load of machines using this DOS based proggy then it might be better to investigate another solution all together...LOL....and again...DOS based progies ONLY print to the infamous LPT1....

584857951[/snapback]

The program is actually designed for use in 1980 for a AIX system and then later ported to DOS. The has been changed to work in a Windows Environment through Acucobol. The company who sells this product has continued to sell it until last month when they came out with a new product based in ASP and MS SQL. We are not prepared yet to upgrade to this product nor do we want to (I don't like being test rats for custom programming).

We use this program on about 30 machine, but disabling LPT1 is not an option for all of them.

This isn't your solution, but I thought you could eliminate the /delete command and just run the following parameter with one net use (if you launch your DOS program separately, then nevermind. This will remove the port redirect after your proggie closes).

net use lpt1 \\computer\printer /Persistent:NO
DOS PROGRAM LAUNCH COMMAND

  Mysterio said:
/delete switch is just a way to CONFIRM that the port is free to use...he's just making sure there's nothing connected to it before his program goes to print to tha port....won't change much....

584858036[/snapback]

Exactly. We also have some users that need to print from this program to different printers, so we have a batch file they can use to switch, but we always want on reboot for it to go back to the default printer.

  Fowen said:
When the batch file is run by Normal Users or Power Users, it pauses asking for a password.  We can not figure out what password it wants.  When it is run by an Administrator, it runs correctly and does not ask for a password. 

This command works fine on any Windows 2000 or Windows NT4 machine, but when I try it on a freshly built Windows XP machine it does not work.  Any idea's?

584857513[/snapback]

Back to the original problem. Have you tested the RunAs command for the XP machine?

runas /user:mymachine\administrator "net use lpt1 \\computer\printer /Persistent:NO"

or

runas /user:domain_id\administrator password "net use lpt1 \\computer\printer /Persistent:NO"

You should get the password prompt now on the XP box.

You could always create a domain account which has limited administrative permissions for LPT1 and incorporate that ID into your batch script. <EDIT>(Of course your users would have to know the password to enter at the prompt. Or you could put the password in plain view in the batch file.)

Edited by paratrupr

If your concern is about the end user knowing the Administrator password, try this FREE solution which will make this entire process much easier.

Get AutoIT3 and compile the following script with your Username and Password. Then the info will be encrypted and the end user can click the .exe to do it all, including launching the DOS proggie.

Create InstallXxxxAsAdmin.au3:

--------------------------------------------------------------------------------------------------
Dim $UserName, $DomainName, $Password, $RunProgram, $RunPath

$UserName = "Administrator"
$DomainName = "YourDomainName"
$Password = "zzzzzzzzzzzzzzzzzzzzzz"

$RunProgram = "net use lpt1 \\computer\printer /Persistent:NO"
$RunPath = "C:\Winnt"


RunAsSet ( $UserName, $DomainName, $Password )

$val = RunWait($RunProgram, $RunPath, @SW_MAXIMIZE)

--------------------------------------------------------------------------------------------------

Compile it, and you will have an binary InstallXxxxAsAdmin.exe

Taken from http://www.experts-exchange.com/Security/W...Q_20933972.html

This app will take care of it for you. Look over the PDF. It doesn't get any easier than this to print to printers from DOS in a Windows NT environment. Absolutely fantastic stable software that has satisfied countless customers of mine. Did I mention this version is free!? DOSPrint.zip

Lemme know if it suits your needs! :D

I just READ this one today....

yeah...AND???....how does that solve the issue at hand????? :angry:

  Fowen said:
Exactly.  We also have some users that need to print from this program to different printers, so we have a batch file they can use to switch, but we always want on reboot for it to go back to the default printer.

584858115[/snapback]

  Mysterio said:
I just READ this one today....

yeah...AND???....how does that solve the issue at hand????? :angry:

584864146[/snapback]

Umm... I am the original poster with the problem thank you very much. I was posting another step in the process.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • No I don't also get my news for one source. Have you considered that maybe I just don't care about tech enough to spend time reading multiple sources? Anyway my website preferences are way off topic.
    • The bloat on windows after 7 was acceptable, but 11 its even worse than chinese android phone makers, because at least they can remove the ads or apps, but w11 shove you bloat with no option to remove it, it seems that 25h2 will fix that
    • When I say I don't see the appeal, I meant as in general, of the character within the story. I guess apart from being a foil, as mentioned, but I still feel it could probably be done a bit more...less on the nose? A bit more nuanced? Something like that. He really just felt more like a chance to cast Fillion more than anything (to me, anyway). Obviously I am aware that Guy Gardner is not exactly meant to be an *appealing* character
    • This excellent 27-inch 1440p 240Hz QD-OLED gaming monitor is way under $500 by Sayan Sen If you are on the hunt for a great gaming monitor that is under $500, then AOC has a great option today that is worth considering. The model in question is the AOC Q27G4ZD which is a 27-inch 240 Hz display based on QD-OLED (Quantum Dot OLED) and it is at just $428 making it lowest ever priced (purchase link under the specs table below). The specialty of QD-OLED is that pairs the self-emissive OLED pixels with a layer of quantum dots, converting blue OLED light into pure red and green wavelengths more efficiently than traditional color filters. The result is brighter highlights, wider color gamut, and higher color volume without sacrificing OLED’s infinite contrast and instant response. Quantum dots are also said to reduce energy loss in color conversion, while boosting luminance and vibrancy. Thanks to the excellent color reproduction alongside the contrast, this QD-OLED monitor can be used for professional photo/video editing, animations, and such as well, plus working on spreadsheets and other office docs should be a breeze too. The technical specifications of the AOC Q27G4ZD are given below: Specification Details Diagonal Screen Size 26.5 " (67.3 cm) Panel Technology Quantum Dot OLED (QD-OLED) Maximum Refresh Rate 240 Hz (DP 1.4) 144 Hz (HDMI 2.0) Response Time (GtG) 0.03 ms (GtG) Brightness (Typ.) 450 cd/m² (10 % APL) Peak Brightness (HDR) 1000 cd/m² (3 % APL) Color Gamuts RGB 100% (CIE1931) / DCI-P3 99% (CIE1976) Color Accuracy Delta E < 2 Display Colors 1.07Billion HDR Certification VESA DisplayHDR™ True Black 400 Sync Technology Adaptive-Sync Contrast Ratio 1,500,000:1 (Typical) Color Depth 10-bit Connectivity 1 × DisplayPort 1.4 2 × HDMI 2.0 1 × 3.5 mm Audio Out 4x USB 3.2 Gen1 Ergonomics Height: 130 mm Tilt: –5 ° ~ 23 ° Swivel: –30 ° ~ 30 ° Pivot: –90 ° ~ 90 ° Bezel 3-sided frameless Special Features Flicker-Free, Low Blue Mode, Gaming Modes (FPS/Racing/RTS/Gamer1–3), Shadow Control, Game Color, Dial Point, Sniper Scope, Low Input Lag Get the AOC Q27G4ZD 27" QD-OLED at the link below: AOC Q27G4ZD 27" QD OLED Gaming Monitor, 3-Year Zero-Bright-Dot: $427.69 (Sold and Shipped by Amazon US) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • But even when it says local, it is not local, they all send info back. I bet if you unplug your computer from the net, they would not work Not saying that AI can't do useful stuff, just I don't want it pushed onto me all the flipping time
  • Recent Achievements

    • Week One Done
      MIghty Haul earned a badge
      Week One Done
    • One Month Later
      MIghty Haul earned a badge
      One Month Later
    • Collaborator
      KD2004 earned a badge
      Collaborator
    • One Month Later
      ataho31016 earned a badge
      One Month Later
    • One Month Later
      Delahenty Machinery earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      594
    2. 2
      Michael Scrip
      200
    3. 3
      ATLien_0
      192
    4. 4
      +FloatingFatMan
      140
    5. 5
      Xenon
      127
  • Tell a friend

    Love Neowin? Tell a friend!