Solved

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

Posted on 2003-10-21
5
903 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

829 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