Thin Client and Virtual Machines Thread, Mapping printers + terminal services in Technical; Hi All, I'm having a lot of trouble getting terminal services to map printers!
Below is the script we're using ...
-
14th October 2011, 03:31 PM #1 Mapping printers + terminal services
Hi All, I'm having a lot of trouble getting terminal services to map printers!
Below is the script we're using along with some debug stuff which was supposed to help us.
Code:
Dim LeftString, netPrinter
Set Sh = CreateObject("WScript.Shell")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")
LeftString = Left(sys, 3)
if leftstring = "HP0" OR leftString = "IEC" then
Set netPrinter = CreateObject("WScript.Network")
netPrinter.AddWindowsPrinterConnection "\\printserver\printer"
netPrinter.SetDefaultPrinter("\\printserver\printer")
else
wscript.echo "Debug, client name: " & sys
end if Now the problem occurs when we use the script fro GPO as a login script. Upon login I get a popup with "Debug, Client name: %clientname%".
BUT! If I run the script manually, from an interactive session, it behaves as expected by either mapping the printer, or giving the debug message displaying the clientname correctly.
Any ideas?
Last edited by tommej; 14th October 2011 at 03:35 PM.
-
-
IDG Tech News
-
16th October 2011, 12:58 AM #2 Maybe the variable doesn't exist at that point, can you get a list of environment variables and see?
I wanted to map printers due to IP, so used GETTSCIP.exe and
Code:
Set WshShell = wscript.CreateObject("WScript.Shell")
Set oExec = WshShell.exec("gettscip.exe")
sOutput = oExec.StdOut.ReadLine
sOutput = Mid(sOutput, 19, len(sOutput)-18)
iparray = split(sOutput,".")
location = CInt(iparray(2))
select case location
case 58
base = "a"
case 59
base = "b"
case 60
base = "c"
case 61
base = "d"
case else
base = CStr(location)
end select
GetTSCIP = base
End Function
-
-
16th October 2011, 06:13 AM #3 I have used this in the past, works well - Printer Addition Based on Location - Wiki
-
-
16th October 2011, 08:05 AM #4 Hi Tommej,
Are you using 2008R2 RDS?
-
-
16th October 2011, 08:10 AM #5 Im going to do a blog post on Printer Mapping with RDS - as Ive just completed a bit project with it. Learnt a hell of a lot, and its taken 3 weeks to get it right. Will update this when I post it.
-
-
17th October 2011, 09:00 AM #6 
Originally Posted by
kmount
Hi Tommej,
Are you using 2008R2
RDS?
Just regular old 2008
-
-
17th October 2011, 09:56 AM #7 You can use group policy preferences with terminal services targeting to deploy printers to specific TS clientnames. I use this for 2008 R2 but it required a hotfix before it would work.
-
-
17th October 2011, 12:07 PM #8 For now I think I have sorted this using powershell and the PSTerminalServices module
Code:
Import-Module PSTerminalServices
$result = Get-TSSession -Filter {$_.Username -like [Environment]::Username} | Select-Object ClientName -expandproperty ClientName
$printServer = "\\printerserver\"
if ($result.contains('IEC')) {
$printer = New-Object -ComObject WScript.Network
$printer.AddWindowsPrinterConnection($printServer + "printername")
$printer.SetDefaultPrinter($printServer + "printername")
}
if ($result.contains('HP0')) {
$printer = New-Object -ComObject WScript.Network
$printer.AddWindowsPrinterConnection($printServer + "printername")
$printer.SetDefaultPrinter($printServer + "printername")
}
if ($result.contains('whatever')) {
$printer = New-Object -ComObject WScript.Network
$printer.AddWindowsPrinterConnection($printServer + "printername")
$printer.SetDefaultPrinter($printServer + "printername")
}
-
SHARE:
Similar Threads
-
By FN-GM in forum Thin Client and Virtual Machines
Replies: 6
Last Post: 4th July 2011, 01:20 PM
-
Replies: 5
Last Post: 1st September 2009, 08:17 PM
-
Replies: 15
Last Post: 1st June 2006, 10:37 AM
-
By Dos_Box in forum Windows
Replies: 4
Last Post: 25th May 2006, 01:26 PM
-
By Norphy in forum Thin Client and Virtual Machines
Replies: 9
Last Post: 12th May 2006, 11:53 AM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules