Solved

Terminal Server across a WAN, Printing from DOS to Network Printers.

Posted on 2003-10-21
5
904 Views
Last Modified: 2012-06-27
Hi, I have windowz 98 boxes that have networked HP 4000tn printers
The w98 clients Terminal serve into the main office across a T.

The networked printer is created and works within all windows applications.
Opening a dos prompt and typing "net use" showed nothing mapped to LPT1 so..

#Script Time, First I delete anything mapped to LPT1
net use lpt1: /delete /y

#Then I get the users ID from the temp directory
for /f "eol=; tokens=6 delims=\ " %%i in ("%TEMP%") do set TSSID=%%i

#Then I get the users printer from the registry and attempt to map it
for /f "Tokens=2 Delims=, " %%i in ('REGfree.EXE -listvalue "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"') do set prt=%%i

#then I set the printers name
set TSPrinterName=%prt% %TSSID%

#Share the printer
rundll32 printui.dll,PrintUIEntry /Xs /n "%TSPrinterName%" sharename "TSPrinter%TSSID%" attributes +Shared

#Map the printer to LPT1
net use lpt1: \\127.0.0.1\TSPrinter%TSSID% /y
:end

This works in windows 2000 but I have trouble with windows 98 boxes getting the:
for /f "Tokens=2 Delims=, " %%i in ('REGfree..........   information
The return value is "HP TSSID"  but the printers name that I need to share is in the reg as "HP Laserjet 4000 series/BOB/Session 3"

Question:
Is there an easier was to share these printers and then map LPT to the shared printer.
Can anyone tell me how to modify the script so that it works on both win98 & win2k

0
Comment
Question by:akourafas
5 Comments
 
LVL 1

Expert Comment

by:Rebelwifi
ID: 9599036
Why not just install the printers on the Terminal Server?

They will then been accessible throughout the network.

0
 
LVL 2

Expert Comment

by:mcrowley
ID: 9602648
I don't suppose Citrix is an option?  Citrix Metaframe would auto-create the printers by group for you, and then your script could do the NET USE.

And are these printers local printers, or networked?  If they are networked, you can use Rebelwifi's suggestion.  Instead of your scripting, you would do -

NET USE lpt1: \\SERVERNAME\PRINTERNAME /y

and be done with it.  Using group policies or other scripting, you could find out who the user was, and assign them to particular printers.
0
 
LVL 2

Expert Comment

by:mcrowley
ID: 9602655
Oh, one other note - If the printers are local to the client, Citrix MF will map the server's lpt1: port to the remote user's lpt1: port, making life much easier for what you're trying to do, I think.
0
 

Accepted Solution

by:
sigbertus earned 250 total points
ID: 9607079
Hello You can use this kix script it works fine for me.

; Get the default printer name and share/map it for DOS apps.
;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.
$WhereisComma = InStr("$DefaultPrinter",",") - 1
$TSPrinterName = Left("$DefaultPrinter","$WhereisComma")

Extracts the Session ID only from the string above.
$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)

;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

0
 
LVL 1

Author Comment

by:akourafas
ID: 9666454
Thanks sigburtus!

I found that awsome script online am unable to get it working. :-(
At lease you confimed I was on the right track.
My hacked up script way was derived from the kix script I couldnt get working & others on the net.
Anything special I need to create in the netlogon directory to get KIX to play happy..
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nslookup is a command line driven utility supplied as part of most Windows operating systems that can reveal information related to domain names and the Internet Protocol (IP) addresses associated with them. In simple terms, it is a tool that can …
Trying to figure out group policy inheritance and which settings apply where can be a chore.  Here's a very simple summary I've written which might help.  Keep in mind, this is just a high-level conceptual overview where I try to avoid getting bogge…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question