Question : Batch Script Help

Hi I am trying to write a batch file to delete old printers and drivers and add the new printers.

It all seems to be working fine except one thing.
Not all of the computers will have the universal print driver.  So the ones that don't have it generates an error which pops up on the screen.  I would like this to be seamless to the user, so if they don't have the driver instead of creating and error and generating a pop up I would like it to just skip it and go to installing the new printers.

Any help would be greatly appreciated.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
REM Delete printers
 
rundll32 printui.dll,PrintUIEntry /dn /n\\PGDC01\PGPR01
rundll32 printui.dll,PrintUIEntry /dn /n\\PGDC01\PGPR02
rundll32 printui.dll,PrintUIEntry /dn /n\\PGDC01\PGPR03
 
 
REM Remove Printer Drivers for Plotter, 9500 & accounting
 
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\%computername% /m "HP LaserJet P2015 Series PCL 5e" /h "Intel" /v "Windows 2000"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\%computername% /m "HP Color LaserJet 9500 mfp PCL 6" /h "Intel" /v "Windows 2000"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\%computername% /m "HP Designjet T1100 44in HPGL2" /h "Intel" /v "Windows 2000"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\%computername% /m "HP Universal Printing PCL6" /h "Intel" /v "Windows 2000"
 
REM Add printers Plotter, 9500 & Accounting
 
rundll32 printui.dll,PrintUIEntry /in /n\\PGDC01\HP9500
rundll32 printui.dll,PrintUIEntry /in /n\\PGDC01\Accounting
rundll32 printui.dll,PrintUIEntry /in /n\\PGDC01\Plotter
Open in New Window Select All

Answer : Batch Script Help

You can try using an IF EXIST statement so it will only try to remove it if it's there:

if exist "filename" (
      goto DELDRIVER
      ) else (
      goto DONTDELDRIVER
      )

:DELDRIVER
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\%computername% /m "HP Universal Printing PCL6" /h "Intel" /v "Windows 2000"

:DONTDELDRIVER
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\%computername% /m "HP LaserJet P2015 Series PCL 5e" /h "Intel" /v "Windows 2000"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\%computername% /m "HP Color LaserJet 9500 mfp PCL 6" /h "Intel" /v "Windows 2000"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\%computername% /m "HP Designjet T1100 44in HPGL2" /h "Intel" /v "Windows 2000"


In this case I'm not positive what the file name will be exactly but this should work if you can get that much
Random Solutions  
 
programming4us programming4us