Jump to content
Sign in to follow this  

Terminal Services - Registry

Recommended Posts


I have spent a couple of days trying to get this to work but i keep going around in circles and wondered if i could get some guidance;


I have a program which requires users to have a printer a set name lets say "printerABC"). Since this is a terminal server when a user logs in and it maps their local printer as PrinterABC (from USERNAME) in session X i have managed to get this working by manually creating a pritner on LTP1 then changing the port to their TSPrint port


Read a set pritner, or users default mapped printer / printer port;

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Pritner ABC(from USERNAME) in session x

Key: Port - TS0xx

Apply this port number to the FIXED printer

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Printer ABC

Key: Port: TS0xx

This will then trick and allow the program to print to the LTP1 Pritner which forwards to the TS Printer Port

The trouble im having is i cannot set a variable in a registry key to update the USERNAME and session X

PrinterABC (from USERNAME) in session X

ie: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Pritner ABC(from $username) in session $sessionNum

if anyone can give me some guidance it would be greatly appricated!


Share this post

Link to post
Share on other sites

So far i have the following;

;Default / mapped printer (will read back the printer / session number of the user)

$printername = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device")

$printername = StringTrimRight($printername, 15)

This is the part im having trouble with; Is it possible to enter the next key like so;

RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\", "$printername")

then export / copy the "port" key

If anyone has anything to add with where i might be going wrong or tips on how i should be writing / arranging the script in general

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...