Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing from DOS App in Terminal Service Remote Desktop 5

Status
Not open for further replies.

centralcity

Technical User
May 1, 2004
6
0
0
US
I'm running a DOS app in a remote desktop using Terminal Services on Win 2003 server.
In order to print from the app, I have to share the printer, then go into a command window (or use a batch file) to map LPT1 to the printer using the "net use" command. In order to issue the "net use" the account has to have administrator privileges. If I then log off, then back on I find that the printer is listed a "unavailable" when I issue a net use command. The only way I've found to restore the printer is to delete, then reinstall the mapping.

I've looked for a way to give this authority to someone other than an administrator, but haven't been able to find it.

Is there a better way to tackle this problem and is there any way to give the authority to capture the printer port with "net use" other than by giving the user administrator privileges.

(BTW, when try to issue the net use command to capture the port with a non-administrator account, I get the message:
The password is invalid for \\server\lj1100
Enter the username for server:
I enter the username of an administrator, then I am asked for password, which I enter. Then I receive the following message "System error 5 has occured. Access is denied")
 
I have exactly the same problem, I can use any other lpt port (2, 3 etc) Just not lpt1! I am using an old DOS app which requires lpt1.
 
I have found a solution to this if you dont need to use the Local LPT1. Disable the port in the device manager, and it works!
 
Thanks to both of you. My problem was solved once I got away from lpt1. Still have to run a batch file once the user logs on to delete, then remap the printers, but it gets the job done. I will be a happy camper if the day ever comes that there are no more DOS apps!!!!
 
I a Dos app that has to print to an LPT port. The printers are not local to the TS. So when a user logs on they are printing back to the printer that was created when logging on.

Does anyone know of an app or way to get around this?
 
Your DOS app has to be able to print to an LPT other than LPT1.

Your Remote Desktop User needs to have "print operator" privileges. Share your printer locally. When you log into RDT, your printer should be shared on the server. If not, share it. then you must use the "Net Use" command to map it to lpt2,3,or4. the computer name will be the name of the server: ex: net use lpt2 \\server\printer

Next, I've found that when you log out and then log back in, the connection is not restored, so you must create a batch file, put it in the startup folder for the user on the server.

The batch file looks like this:

net use lpt2 /delete
net use lpt2 \\server\printer

This will delete, then recreate the share and the printer will be connected for the duration of the remote session
 
If you use
Net Use LPT1: \\computername\printershare /persistent:yes
It will remember every time you log back in. You need the persistent to always remember each time you log in and out. Type it in once and it should know everytime.
 
Dmasch, you solution will fail under XP for the reasons I gave the MS KB link above.

I was reminded of a script by Claudio Rodgriguez, MVP, and I offer it below:


; Get the default printer name and share/map it for DOS apps.
; By Cláudio Rodrigues, ; Example String: HP LaserJet 4Si/CLAUDIOXP/Session 1,winspool,TS002

;Reads the default printer from the registry.
$DefaultPrinter = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows","Device")

;Extracts the printer name on the TS. Example: HP LaserJet
4Si/CLAUDIOXP/Session 1
$WhereisComma = InStr("$DefaultPrinter",",") - 1
$TSPrinterName = Left("$DefaultPrinter","$WhereisComma")

;Extracts the machine name/Session ID. Example: CLAUDIOXP/Session 1
$WhereisSlash = InStr("$TSPrinterName","/") - 1
$MachineAndSSID = Left("$DefaultPrinter","$WhereisSlash")

;Extracts the Session ID only from the string above. Example: 1
$PosTemp = InStr("$TSPrinterName","/")
$EndTemp = Len("$TSPrinterName") - $PosTemp
$TempStr = Right("$TSPrinterName","$EndTemp")
$PosTemp = InStr("$TempStr","/")
$EndTemp = Len("$TempStr") - $PosTemp
$TempStr = Right("$TempStr","$EndTemp")
$Pos2 = InStr("$TempStr"," ")
$End3 = Len("$TempStr") - $Pos2
$SSID = Right("$TempStr","$End3")

$ShareName = "TSPrinter" + $SSID
$TSPrinterName = chr(34) + $TSPrinterName + chr(34)

If Len($LocalPrinter) <> 0
then
$TSPrinterName = chr(34) + $LocalPrinter + $MachineAndSSID + chr(34)
EndIf

;Shares the printer.
USE LPT1: /DELETE
Shell 'rundll32 printui.dll,PrintUIEntry /Xs /n $TSPrinterName sharename
$Sharename attributes +Shared'
$PrinterOnTS = "\\127.0.0.1\" + $ShareName
USE LPT1: $PrinterOnTS

Your users MUST BE power users under Win2k, or use Devcon.exe as explained earlier under XP; otherwise the script WILL NOT WORK
 
Hi Centralcity, were you able to resolve this issue regarding the net use LPT1? I am getting the same problem adding the net use lpt1... line to my batch file to run DOS program that we use. Initially it will say password is invalid for the \\servername\printer share. Then it will ask to enter the user name and the pasword, but once you typed in it will say "System error 5 has occurred" then "Access Denied" The only thing that sould make program batch file work is to assign Domain Admin roghts to user which is ridiculous. If you happen to solve this please post it here... thanks
 
You CANNOT use LPT1. It's been a while since I went through it, so I can't remember the exact reason. But as long as you map to an lpt other than 1, the procedures will work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top