Solved

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

Posted on 2003-10-21
5
894 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
Greetings, Experts! First let me state that this website is top notch. I thoroughly enjoy the community that is shared here; those seeking help and those willing to sacrifice their time to help. It is fantastic. I am writing this article at th…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now