Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Using renameprinter to change a printer name on Server 2008

Reply
 
Old 10-28-2008   #1 (permalink)
Saucer Man


 
 

Using renameprinter to change a printer name on Server 2008

I am trying to change the names of printers on Windows Server 2008. The
script works on XP and should work on Server 2008 but it isn't. Here is the
script...

Dim EndPos

strComputer = "."

Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer Where
DeviceID Like '%redirected%'")

For Each objPrinter in colPrinters
EndPos = InStr(objPrinter.name,"redirected") -1
objPrinter.name = Left(objPrinter.name, EndPos) & "redirected)"
msgbox objprinter.name
'objPrinter.RenamePrinter(objPrinter.name)
Next


Any ideas how to fix this"?
--
Thanks!



My System SpecsSystem Spec
Old 10-31-2008   #2 (permalink)
Saucer Man


 
 

Re: Using renameprinter to change a printer name on Server 2008

Anyone?

"Saucer Man" <saucerman@xxxxxx> wrote in message
news:49070da9$0$5734$cc2e38e6@xxxxxx
Quote:

>I am trying to change the names of printers on Windows Server 2008. The
>script works on XP and should work on Server 2008 but it isn't. Here is
>the script...
>
> Dim EndPos
>
> strComputer = "."
>
> Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
>
> Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer
> Where DeviceID Like '%redirected%'")
>
> For Each objPrinter in colPrinters
> EndPos = InStr(objPrinter.name,"redirected") -1
> objPrinter.name = Left(objPrinter.name, EndPos) & "redirected)"
> msgbox objprinter.name
> 'objPrinter.RenamePrinter(objPrinter.name)
> Next
>
>
> Any ideas how to fix this"?
> --
> Thanks!
>
>

My System SpecsSystem Spec
Old 01-07-2009   #3 (permalink)
Sander Verroen


 
 

RE: Using renameprinter to change a printer name on Server 2008

If your statement spans multiple rows, you should end your statement with a _
or put the full statement on 1 row.

Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer Where _
DeviceID Like '%redirected%'")

My System SpecsSystem Spec
Old 01-07-2009   #4 (permalink)
ekkehard.horner


 
 

Re: Using renameprinter to change a printer name on Server 2008

Sander Verroen schrieb:
Quote:

> If your statement spans multiple rows, you should end your statement with a _
> or put the full statement on 1 row.
>
> Set objWMIService = GetObject("winmgmts:" & _
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer Where _
> DeviceID Like '%redirected%'")
>
==>
Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer Where " _
& "DeviceID Like '%redirected%'")
My System SpecsSystem Spec
Old 02-03-2009   #5 (permalink)
Saucer Man


 
 

Re: Using renameprinter to change a printer name on Server 2008

I do have the statements on 1 line. It just looks like two here in the
post. Thanks.


"ekkehard.horner" <ekkehard.horner@xxxxxx> wrote in message
news:4964708c$0$31871$9b4e6d93@xxxxxx-online.net...
Quote:

> Sander Verroen schrieb:
Quote:

>> If your statement spans multiple rows, you should end your statement with
>> a _ or put the full statement on 1 row.
>>
>> Set objWMIService = GetObject("winmgmts:" & _
>> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>>
>> Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer
>> Where _
>> DeviceID Like '%redirected%'")
> ==>
> Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer
> Where " _
> & "DeviceID Like '%redirected%'")
>

My System SpecsSystem Spec
Old 02-03-2009   #6 (permalink)
ekkehard.horner


 
 

Re: Using renameprinter to change a printer name on Server 2008

Saucer Man schrieb:
Quote:

> I do have the statements on 1 line. It just looks like two here in the
> post. Thanks.
I just pointed out the typo in Sander Verroen's second code snippet. So I
don't deserve your thanks. (You are welcome anyway)
Quote:

>
>
> "ekkehard.horner" <ekkehard.horner@xxxxxx> wrote in message
> news:4964708c$0$31871$9b4e6d93@xxxxxx-online.net...
Quote:

>> Sander Verroen schrieb:
Quote:

>>> If your statement spans multiple rows, you should end your statement with
>>> a _ or put the full statement on 1 row.
>>>
>>> Set objWMIService = GetObject("winmgmts:" & _
>>> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>>>
>>> Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer
>>> Where _
>>> DeviceID Like '%redirected%'")
>> ==>
>> Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer
>> Where " _
>> & "DeviceID Like '%redirected%'")
>>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Error when installing SQL Express 2008 on Windows Server 2008 PowerShell
Install Virtual Machine additions on Server 2008 server core. Virtual PC
SQL Server Express 2008 & VS 2008 .NET General
How do I set up SCVMM 2008 to interface with Hyper-V Server 2008? Virtual Server
Windows 2008 print server at terminal services - printer driver problem Vista print fax & scan


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46