?
Solved

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

Posted on 2003-10-21
5
Medium Priority
?
915 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 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

Limited time offer using promo code EXPERTS25

Designed with a wealth of functionality and convenience, ATEN's new Thunderbolt™ 2 Sharing Switch takes your Thunderbolt setup to the next level. Now through August 31, 2017, Experts Exchange members get 25% off the US7220 on the ATEN USA eShop using promo code EXPERTS25.

Question has a verified solution.

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

This article is in response to a question (http://www.experts-exchange.com/Networking/Network_Management/Network_Analysis/Q_28230497.html) here at Experts Exchange. The Original Poster (OP) requires a utility that will accept a list of IP addresses …
The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

771 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