Mapped printers in VB Script give error of the filename directory name syntax is incorrect. I can run it manually.

I am running a domain controller and a terminal services box on the same server.  I have a VB Script running that maps printers.  I run this in under a Group Policy of User Configuration>Windows Settings>Scripts>Logon.  This is the script:

Dim multiPrinter, printer1, printer2
printer1 = "\\\Ogden-HP"
printer2 = "\\\SmartLab"
Set multiPrinter = CreateObject("WScript.Network")
multiPrinter.AddWindowsPrinterConnection printer1
multiPrinter.AddWindowsPrinterConnection printer2

REM Un-REM The following line to set the Minolta Copier as the user's default printer
REM multiPrinter.SetDefaultPrinter printer1

It give me an error message of the filename directory name syntax is incorrect, but if I run the script manually it maps the printers just fine.

Please Help!! And thanks for any responses in advance!!!!!
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.

Muhammad KhanManager, ITCommented:
The startup script might be running even before the network connections are fully established... check the following link to see your options of delayed execution of script
tshobeAuthor Commented:
I tried this and it still didn't work.  Any other thoughts?  I do appreciate your help.
greg wardSystems EngineerCommented:

Option Explicit
Dim objPrinters, objShell, objNetwork, strUNCPrinter1, strUNCPrinter2
Set objPrinters = WScript.CreateObject("WScript.Network")
Set objShell = WScript.CreateObject("WScript.Shell")
strUNCPrinter1 = "\\server\printer"
strUNCPrinter2 = "\\server\printer"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strUNCPrinter1
objNetwork.AddWindowsPrinterConnection strUNCPrinter2
objNetwork.SetDefaultPrinter strUNCPrinter1
works for me

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
tshobeAuthor Commented:
Thank you for your help.  I really appreciate it.
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
VB Script

From novice to tech pro — start learning today.