Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Shorten printer name on remote desktop logon

$
0
0

I need to run a script when a user logs on using Remote Desktop.  I have an application that doesn't accept printer names over 24 characters long.  I've searched and searched and have the below code, but it doesn't seem to work.  I have it set to run at Logon in the GPO.  My knowledge is very limited in all of this.

Set WshShell = WScript.CreateObject("WScript.Shell")

WScript.Sleep 2000

on error Resume Next
lngMaxCharsAllowed = 24
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
For Each objItem in colItems
   if len(objItem.Name) > lngMaxCharsAllowed then
    objItem.RenamePrinter(left(IDNew & " " &objItem.Name, lngMaxCharsAllowed))
   end if
Next

Wscript.quit


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>