Link to home
Start Free TrialLog in
Avatar of samiam41
samiam41Flag for United States of America

asked on

Script to check for multiple print queues

Experts!  I have a login script that kicks off another script called Printer.bat.  This second script maps print queues based on the group membership of the user account.  Each printer has two Windows groups named after them (PTR-xxx and PTR-xxx-D.  If the user is apart of the first group, the script adds the printer and continues running until it finds a group that ends with -D.  The -D makes the printer the default printer.

The problem I am running into is that the printer.bat script finds the -D group first and doesn't add any more printers.  Is there a way to modify the script to make sure there is at least two print queues before finishing?  That way, if the -D group is found first, it will search for one more group and then quit.  I am including the script I am using (which is compliments of another expert).
@echo off
setlocal enabledelayedexpansion
echo Connecting Printers...
set PriorityDefaultPrinterSet=0
for /f "tokens=1-3 delims=-." %%a in ('M:\ifmember.exe /list ^| find /i "group %UserDomain%\Prt-" ^| sort') do (
  rundll32 printui.dll,PrintUIEntry /in /q /n\\w2k3ps01\%%b
  if "!PriorityDefaultPrinterSet!"=="0" rundll32 printui.dll,PrintUIEntry /y /n\\w2k3ps01\%%b
  if /i "%%c"=="D" set PriorityDefaultPrinterSet=1
)
 
exit

Open in new window

Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

I would need to see the output of the for loop.

So, can you ...

M:\ifmember.exe /list | find /i "group %UserDomain%\Prt-" | sort

at the cmd prompt.

I don't have ifmember.exe so I don't know the exact output.

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oBdA
oBdA

Oh, and please add the following line at the end as line 20:

>>"%LogFile%" echo %~nx0 ended.

Open in new window

Avatar of samiam41

ASKER

Outstanding post.  I will test this when I get into the office tomorrow morning.  Thanks for your time.
sorry i haven't posted back.  i should have updated info tomorrow morning.  thank you for your patience.
I got stuck with a Websense issue and server collapse.  Sorry for not responding quicker.  You were right.  I didn't give it enough time for the replication to take place before testing.  Great work as always.
oBdA/RQuadling:  

I know you gents are busy but I would really appreciate any help you can offer on this one.  The current expert is trying to assist but isn't able to address the question.  Thank you!

https://www.experts-exchange.com/questions/23566937/Capture-data-from-website-dump-to-csv-file.html