Find printer registry

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Jfmichaud
Posts: 2
Joined: 19 Feb 2012 21:05

Find printer registry

#1 Post by Jfmichaud » 19 Feb 2012 21:17

Hi i'm looking for a way to search in the registry a certain printer if it finds that printer, exit the rest of the batch file else continu the batch file. Here is what i've got

Code: Select all

reg query ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices" ^|find /I "TOSHIBA e-STUDIO555Series PS3 Photocopieur"') Do (
  If "%%I"=="TOSHIBA e-STUDIO555Series PS3 Photocopieur" (
     GOTO EOF
  ) ELSE (
     net use P: \\10.10.10.46\partage\PS555 /persistent:No
xcopy /Q /h /Y P:\*.* c:\temp\
c:\temp\PrintDBGSP.vbs
c:\temp\SUBINACL /verbose=1 /printer "TOSHIBA e-STUDIO555Series PS3 Photocopieur" /grant="Tout le monde"=F
net use P: /delete /y
del c:\temp /F /Q
  )
)


Thanks for the help

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Find printer registry

#2 Post by foxidrive » 20 Feb 2012 01:17

Try this:

Code: Select all


removed incorrect code so future googlers will not be sidetracked.

Last edited by foxidrive on 20 Feb 2012 08:17, edited 1 time in total.

Jfmichaud
Posts: 2
Joined: 19 Feb 2012 21:05

Re: Find printer registry

#3 Post by Jfmichaud » 20 Feb 2012 08:06

Thanks for the help

i'm still having problem it says error key name not valid...type reg query /? for syntax

:(

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Find printer registry

#4 Post by foxidrive » 20 Feb 2012 08:16

I didn't realise that your reg command was fubar.

Try this - it should only proceed with the following code if that "TOSHIBA e-STUDIO555Series PS3 Photocopieur" string is not found.
I am assuming that your reg query is querying the right key and that string is the correct one.


Code: Select all

@echo off
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices" |find /I "TOSHIBA e-STUDIO555Series PS3 Photocopieur" >nul && (
net use P: \\10.10.10.46\partage\PS555 /persistent:No
xcopy /Q /h /Y P:\*.* c:\temp\
c:\temp\PrintDBGSP.vbs
c:\temp\SUBINACL /verbose=1 /printer "TOSHIBA e-STUDIO555Series PS3 Photocopieur" /grant="Tout le monde"=F
net use P: /delete /y
del c:\temp /F /Q
  )


Post Reply