|I am writing a batch script to update about 300 offsite Windows XP systems. I am resetting various printer information and downloading new drivers. At one point, I need to check whether their default printer is set as a particular printer (Zebra Printer) and if so, I have to set it to the new option (Zebra Label Printer) so that it will use the new driver. So within the batch script, I call another script which consists of|
REM Skip the first 3 lines, then assign the 4th line to a variable.
for /f "tokens=* skip=3 delims= " %%a in (c:\temp\default-printer.txt) do (
if !myvar!'==' set myvar=%%a
REM Replace the "The default printer is" phrase with all blanks.
set myvar=%myvar:The default printer is= %
REM Now left trim the variable
for /f "tokens=* delims= " %%a in ("%myvar%") do set myvar=%%a
IF !myvar! == "Zebra Printer" rundll32 printui.dll,PrintUIEntry /y /n "Zebra Label Printer"
REM And output the result.
That last line is just a way for me to test this script at the command line to make sure it is pulling the correct information. The problem I am running into is my last IF statement - the rundll32 entry which sets the new default printer - it is not running that command. If I run that whole command (rundll32 printui.dll,PrintUIEntry /y /n "Zebra Label Printer") at the command line, it works fine, but it is not working within the batch script. Do I enclose it in quotes. brackets, something else?
Any help would be appreciated, thank you!