Group:  English: Windows Server ยป microsoft.public.windows.server.scripting
Thread: setprinter command

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

setprinter command
don 10.07.2007 19:18:04
has anyone used the setprinter command?

i want to be able to use it to point printers to another driver so that i
can delete the current driver they are currently using

I cannot delete the current driver because it says it is in use

has anyone had any experience with this

thanks
don

Re: setprinter command
"Alan Morris [MSFT]" <alanmo[ at ]online.microsoft.com> 11.07.2007 17:09:01
plagerism from a co worker

Rich has a script called changedrivers.cmd

copy all below this line and create your own cmd file
------------------------------------------------------------

[ at ]echo off
setlocal enableextensions

if %3.==. goto usage

set NoMath=
:: set NoMath=REM
set Svr=%1
set OldDrv=%2
set NewDrv=%3

%NoMath% set /a Cnt=0

for /f "tokens=1,2 delims==" %%A in ('setprinter -show "%Svr%" 2 ^| findstr
"pPrinterName= pDriverName="') do call :ReplaceDriver %%A %%B%

[ at ]echo.
if "%NoMath%"=="" set Cnt=All
[ at ]echo. %Cnt% %OldDrv% drivers replaced with %NewDrv%
[ at ]echo.

goto :EOF

:ReplaceDriver tag "value"
:: save printer name
if /i "%1"=="pPrinterName" set PrtName=%2& goto :EOF
:: is target driver?
if /i NOT %2==%OldDrv% goto :EOF
:: Replace driver with new driver
[ at ]echo Replacing driver on queue %PrtName%. Old: %2, New: %NewDrv%
SetPrinter %PrtName% 2 pDriverName=%NewDrv%
if errorlevel 1 [ at ]pause
%NoMath% set /a Cnt+=1
goto :EOF

:Usage
[ at ]echo.
[ at ]echo Change all printers which are using driver X to use driver Y
[ at ]echo.
[ at ]echo %0 \\SvrName "Old Driver" "New Driver"
[ at ]echo.
goto :EOF




--
Alan Morris
Windows Printing Team
Search the Microsoft Knowledge Base here:
http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto

This posting is provided "AS IS" with no warranties, and confers no rights.

"don" <don[ at ]discussions.microsoft.com> wrote in message
news:CDCCBE56-E6D9-469E-9971-28693280FF55[ at ]microsoft.com...
[Quoted Text]
> has anyone used the setprinter command?
>
> i want to be able to use it to point printers to another driver so that i
> can delete the current driver they are currently using
>
> I cannot delete the current driver because it says it is in use
>
> has anyone had any experience with this
>
> thanks
> don
>


Re: setprinter command
don 12.07.2007 13:58:05
Hi Alan

thank you very much for this, i am afraid i dont have much experience with
this and therefore need some help with understanding it.

I have saved it as a CMD file but am unable to run it as it is - what
changes do i need to make to it to suit my environment and make it work?

For example, server name is Mickey-SA - i have about 600 printers to update
with the new driver

thanks
Don

"Alan Morris [MSFT]" wrote:

[Quoted Text]
> plagerism from a co worker
>
> Rich has a script called changedrivers.cmd
>
> copy all below this line and create your own cmd file
> ------------------------------------------------------------
>
> [ at ]echo off
> setlocal enableextensions
>
> if %3.==. goto usage
>
> set NoMath=
> :: set NoMath=REM
> set Svr=%1
> set OldDrv=%2
> set NewDrv=%3
>
> %NoMath% set /a Cnt=0
>
> for /f "tokens=1,2 delims==" %%A in ('setprinter -show "%Svr%" 2 ^| findstr
> "pPrinterName= pDriverName="') do call :ReplaceDriver %%A %%B%
>
> [ at ]echo.
> if "%NoMath%"=="" set Cnt=All
> [ at ]echo. %Cnt% %OldDrv% drivers replaced with %NewDrv%
> [ at ]echo.
>
> goto :EOF
>
> :ReplaceDriver tag "value"
> :: save printer name
> if /i "%1"=="pPrinterName" set PrtName=%2& goto :EOF
> :: is target driver?
> if /i NOT %2==%OldDrv% goto :EOF
> :: Replace driver with new driver
> [ at ]echo Replacing driver on queue %PrtName%. Old: %2, New: %NewDrv%
> SetPrinter %PrtName% 2 pDriverName=%NewDrv%
> if errorlevel 1 [ at ]pause
> %NoMath% set /a Cnt+=1
> goto :EOF
>
> :Usage
> [ at ]echo.
> [ at ]echo Change all printers which are using driver X to use driver Y
> [ at ]echo.
> [ at ]echo %0 \\SvrName "Old Driver" "New Driver"
> [ at ]echo.
> goto :EOF
>
>
>
>
> --
> Alan Morris
> Windows Printing Team
> Search the Microsoft Knowledge Base here:
> http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "don" <don[ at ]discussions.microsoft.com> wrote in message
> news:CDCCBE56-E6D9-469E-9971-28693280FF55[ at ]microsoft.com...
> > has anyone used the setprinter command?
> >
> > i want to be able to use it to point printers to another driver so that i
> > can delete the current driver they are currently using
> >
> > I cannot delete the current driver because it says it is in use
> >
> > has anyone had any experience with this
> >
> > thanks
> > don
> >
>
>
>
Re: setprinter command
"Alan Morris [MSFT]" <alanmo[ at ]online.microsoft.com> 12.07.2007 16:22:06
this only requires setprinter in the path and admin rights on the remote
machine

YOURCMDNAME \\SvrName "Old Driver" "New Driver"


You have to "" the driver names since they have spaces.

Are you getting a specific error?

--
Alan Morris
Windows Printing Team
Search the Microsoft Knowledge Base here:
http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto

This posting is provided "AS IS" with no warranties, and confers no rights.

"don" <don[ at ]discussions.microsoft.com> wrote in message
news:3B00AF19-8EE4-4DB8-A28B-F01A400D556F[ at ]microsoft.com...
[Quoted Text]
> Hi Alan
>
> thank you very much for this, i am afraid i dont have much experience with
> this and therefore need some help with understanding it.
>
> I have saved it as a CMD file but am unable to run it as it is - what
> changes do i need to make to it to suit my environment and make it work?
>
> For example, server name is Mickey-SA - i have about 600 printers to
> update
> with the new driver
>
> thanks
> Don
>
> "Alan Morris [MSFT]" wrote:
>
>> plagerism from a co worker
>>
>> Rich has a script called changedrivers.cmd
>>
>> copy all below this line and create your own cmd file
>> ------------------------------------------------------------
>>
>> [ at ]echo off
>> setlocal enableextensions
>>
>> if %3.==. goto usage
>>
>> set NoMath=
>> :: set NoMath=REM
>> set Svr=%1
>> set OldDrv=%2
>> set NewDrv=%3
>>
>> %NoMath% set /a Cnt=0
>>
>> for /f "tokens=1,2 delims==" %%A in ('setprinter -show "%Svr%" 2 ^|
>> findstr
>> "pPrinterName= pDriverName="') do call :ReplaceDriver %%A %%B%
>>
>> [ at ]echo.
>> if "%NoMath%"=="" set Cnt=All
>> [ at ]echo. %Cnt% %OldDrv% drivers replaced with %NewDrv%
>> [ at ]echo.
>>
>> goto :EOF
>>
>> :ReplaceDriver tag "value"
>> :: save printer name
>> if /i "%1"=="pPrinterName" set PrtName=%2& goto :EOF
>> :: is target driver?
>> if /i NOT %2==%OldDrv% goto :EOF
>> :: Replace driver with new driver
>> [ at ]echo Replacing driver on queue %PrtName%. Old: %2, New: %NewDrv%
>> SetPrinter %PrtName% 2 pDriverName=%NewDrv%
>> if errorlevel 1 [ at ]pause
>> %NoMath% set /a Cnt+=1
>> goto :EOF
>>
>> :Usage
>> [ at ]echo.
>> [ at ]echo Change all printers which are using driver X to use driver Y
>> [ at ]echo.
>> [ at ]echo %0 \\SvrName "Old Driver" "New Driver"
>> [ at ]echo.
>> goto :EOF
>>
>>
>>
>>
>> --
>> Alan Morris
>> Windows Printing Team
>> Search the Microsoft Knowledge Base here:
>> http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> "don" <don[ at ]discussions.microsoft.com> wrote in message
>> news:CDCCBE56-E6D9-469E-9971-28693280FF55[ at ]microsoft.com...
>> > has anyone used the setprinter command?
>> >
>> > i want to be able to use it to point printers to another driver so
>> > that i
>> > can delete the current driver they are currently using
>> >
>> > I cannot delete the current driver because it says it is in use
>> >
>> > has anyone had any experience with this
>> >
>> > thanks
>> > don
>> >
>>
>>
>>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net