Wise112 Posted July 15, 2010 Share Posted July 15, 2010 Hello, 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; Overview: 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 Aim: 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! Tim Link to comment Share on other sites More sharing options...
Wise112 Posted July 15, 2010 Author Share Posted July 15, 2010 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now