DOS printing through Terminal server

J

jmajor

I'm using Terminal Server on 2 Windows 2000 server
machines. Our clients connect to Terminal server via a VPN
and need to print from DOS programs to they're local
printers. Essentially , the client needs to map lpt1 on
they're terminal server session. Since the clients local
printer must be shared in order for terminal server to
create a print session they cannot map LPT1.

Please help!
 
C

Cláudio Rodrigues

Use this script. Save it as PrintDOS.KIX and get KIX32 from
http://www.kixtart.org.
Then change USRLOGON.CMD on the TS to call this script.

; Get the default printer name and share/map it for DOS apps.
; By Cláudio Rodrigues, http://www.Terminal-Services.NET
; Example String: HP LaserJet 4Si/CLAUDIOXP/Session 1,winspool,TS002

;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. Example: HP LaserJet
4Si/CLAUDIOXP/Session 1
$WhereisComma = InStr("$DefaultPrinter",",") - 1
$TSPrinterName = Left("$DefaultPrinter","$WhereisComma")

;Extracts the machine name/Session ID. Example: CLAUDIOXP/Session 1
$WhereisSlash = InStr("$TSPrinterName","/") - 1
$MachineAndSSID = Left("$DefaultPrinter","$WhereisSlash")

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

If Len($LocalPrinter) <> 0
then
$TSPrinterName = chr(34) + $LocalPrinter + $MachineAndSSID + chr(34)
EndIf

;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

Users MUST be power users though thanks to the way MS implemented a couple
things regarding printing on Windows 2000.

--
Cláudio Rodrigues, MVP
Windows 2000/NT Server
Terminal Services

http://www.terminal-services.NET

-> The only Terminal Services Client for DOS.
-> The only customized RDP5.1 client with the close button disabled! :)
-> Developers of SecureRDP, the BEST security utility for TS!

Do NOT email me directly UNLESS YOU KNOW ME or you are a Microsoft
MVP/Employee.
Use my support page on my website to submit your questions directly.
 
J

jmajor

Claudio,

Thank you for you prompt response. However I am getting an
error when I run this script with Kix32:

'Printer rundll command failed.
'Command" /Xs /n "" sharename
'TSPrinter attributes + shared. Operation could not be
completed.

Please help!

Jmajor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top