How to set the default printer with a batch file in a roaming profile?


We have a Windows AD network at my work.  We have local profiles for PC's and laptops; but we use roaming profile when users logon to Citrix Farm.  The roaming profiles are created in the Remote Desktop Services profile tab, in Active Directory.  The Citrix Farm Servers are Windows 2008 R2 Sp1.

One user is having a problem with his default printer continuously changing on him.  I think that his local printer is for some reason not keeping the normal default printer and it randomly puts another printer as the default.  Then the said users logas on via Remote Desktop and his remote desktop default printer is this other printer.

I am thinking of creating a batch file on the user's laptop (startup folder) to select the desired printer to always be his default.

put in the c:\ProgramData\Microsoft\Windows\Start Menu\programs\Startup, on the user's Windows 7 laptop.

REM Set printer as default
rundll32 printui.dll,PrintUIEntry /y /n\\Printer_Server_Name\Printer_Share_Name

But is there a way to force the default printer to be set after the user logs on to the Citrix Server?  Can I put the same batch file on the Citrix Server's local profile settings, for this user?  Perhaps put a delay of 10 seconds in order to wait for all of the printers to load first and then execute the batch file?
PkafkasNetwork EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PkafkasNetwork EngineerAuthor Commented:
Could it be in:  C:\Users\UserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs - folder

How can I put a delay in the batch file?

Should I use a sleep command?  //sleep does not seem to work.  Any other commands that can pause the execution of the batch file?

sleep 20
rundll32 printui.dll,PrintUIEntry /y /n\\COMPUTER\PRINTER
PkafkasNetwork EngineerAuthor Commented:
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
REM Set Pritner as default
timeout /t 20 /NOBREAK
rundll32 printui.dll,PrintUIEntry /y /n\\Server_NAME\Pritner_SHARE_NAME

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PkafkasNetwork EngineerAuthor Commented:
No one replied and I figured this out myself.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.