Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2003-10-21
5
Medium Priority
?
920 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

FIPS stands for the Federal Information Processing Standardisation and FIPS 140-2 is a collection of standards that are generically associated with hardware and software cryptography. In most cases, people can refer to this as the method of encrypti…
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…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 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