VBScript, trim and append to WMI object name

In our Win2003 Server and XP Pro workstation environment, the logon scripts install as many as 12 network printer drivers to each workstation.  Each printer driver that is installed locally via the logon scripts gets the tag "-ASD01" appended to printer name.  For example, if we click on Start | Settings | Printers & Faxes to display the print driver list, each automatically installed driver will end with -ASD01, such as HP LaserJet4-ASD01  -- where as if you manually installed that driver (not via login scripts) it would display as HP LaserJet 4.  The network login scripts are protected and we cannot edit them, however, WSH is enabled on workstations so that VBScript works.  We need help with a VBS that does 2 things: i) it trims the -ASD01 off each printer name in the local WS printer list, and ii) it appends a user supplied string that is to display at end of the DeviceID string (this user supplied string will identify driver type, version and other info - it does not have to be more than 8 chars).  Here is the beginnings of that vb script, is anyone able to manipulate strings to trim the unwanted right-most chars, then (preferably in a separate line) append mmyy?  

--- Code begins ---
On Error Resume Next
StrComputer = "."
Set objWMIService = GetObject("winmgmts:\\"& strComputer &"\root\cimv2")
Set ColItems = objWMIService.ExecQuery("Select * from win32_printer where DeviceID like '%-ADS01%'")
For each objItem in ColItems
*Note1: our code is missing line(s) here that would modify DeviceID so as to trim "-ASD01" off
*Note2: our code is missing line(s) here that would append mmyy (we will modify the file to supply appropriate
wscript.echo objItem.DeviceID

----- end of code example ---

The succesful code would change
HP LaserJet 4-ASD01
to this (the 8 new chars are supplied by user who edits the vb script text file)
HP LaserJet 4-PSv3    

Appreciate any help with this WMI object string manipulation issue. Thx!
BITASCIIAV Technology SupportAsked:
Who is Participating?
Psy053Connect With a Mentor Commented:
I just had a read through this: http://msdn.microsoft.com/en-us/library/aa394363(VS.85).aspx and put the following snippet together - unfortunately though, it's pretty much just a theory as I have no way of testing it - so I really suggest testing offline if possible.

' This section relates to Note 1, and should remove -ADS01
strNewName = Left(objItem.DeviceID, (Len(objitem.DeviceID) - 6))
Wscript.Echo objItem.DeviceID

' This section related to Note 2, and should add -PSv3
objitem.RenamePrinter(objItem.Device & "-PSv3")
Wscript.Echo objItem.DeviceID

Open in new window

Hi there,

Is ASD01 a constant for every printer?  If so, then you could just use
strMyString = Replace(objItem.DeviceID, "-ASD01", "-PSv3")


BITASCIIAV Technology SupportAuthor Commented:
Thanks much for the solution and helping us understand that the 'RenamePrinter' method is needed to achive stated goals.  Thx again!
All Courses

From novice to tech pro — start learning today.