Need Help With Error Code 8007007B on VB Script

I have a script residing on a centralized share. The end user's PCs have a shortcut at startup that points to this script. Every time someone logs onto the computer it runs the script and maps the listed network printers. Intermittently they get an 8007007B error. It doesn't happen all the time and it no specific order, the error seems to be generating at random. The error happens on several computers with different users including people with admin rights on the domain. I've read allot of post and tried different solutions but they all generate a different error. All the systems that run script via shortcut are XP Pro machines. The script resides on a share on a Windows 2003 print server.

This is my script:

Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\ford\blue4100"
net.AddWindowsPrinterConnection "\\ford\Royal1RX"
net.AddWindowsPrinterConnection "\\ford\Royal2"
net.AddWindowsPrinterConnection "\\ford\Green1RX"
net.AddWindowsPrinterConnection "\\ford\Green2"
net.AddWindowsPrinterConnection "\\ford\Mid1"
net.AddWindowsPrinterConnection "\\ford\Mid2RX"

This is the error:
Script:   \\ford\printmap\pmap.vbs
Line:     9
Char:    1
Error:    the filename, directory name, or volume label syntax is incorrect.
Code:    8007007B
Source: (null)
LVL 1
t3nguAsked:
Who is Participating?

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

x
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.

RobSampsonCommented:
Hi, if this is only intermittent, then you may have connectivity issues while trying to connect to printers. Perhaps some are offsite?

Try this code, which will attempt to connect to the printer up to 10 ten times, and sleep for 2 seconds on every failed attempt before trying again.

Regards,

Rob.
MapPrinter "\\ford\blue4100"
MapPrinter "\\ford\Royal1RX"
MapPrinter "\\ford\Royal2"
MapPrinter "\\ford\Green1RX"
MapPrinter "\\ford\Green2"
MapPrinter "\\ford\Mid1"
MapPrinter "\\ford\Mid2RX"
 
Sub MapPrinter(strPrinter)
    On Error Resume Next
    Set objNetwork = CreateObject("WScript.Network")
    boolConnected = False
    intAttempts = 1
    While boolConnected = False And intAttempts <= 10
        Err.Clear
        objNetwork.AddWindowsPrinterConnection strPrinter
        If Err.Number <> 0 Then
            intAttempts = intAttempts + 1
            WScript.Sleep 2000
        Else
            boolConnected = True
        End If
    Wend
End Sub

Open in new window

0
RobSampsonCommented:
Forgot to turn errors back on....
MapPrinter "\\ford\blue4100"
MapPrinter "\\ford\Royal1RX"
MapPrinter "\\ford\Royal2"
MapPrinter "\\ford\Green1RX"
MapPrinter "\\ford\Green2"
MapPrinter "\\ford\Mid1"
MapPrinter "\\ford\Mid2RX"
 
Sub MapPrinter(strPrinter)
    On Error Resume Next
    Set objNetwork = CreateObject("WScript.Network")
    boolConnected = False
    intAttempts = 1
    While boolConnected = False And intAttempts <= 10
        Err.Clear
        objNetwork.AddWindowsPrinterConnection strPrinter
        If Err.Number <> 0 Then
            intAttempts = intAttempts + 1
            WScript.Sleep 2000
        Else
            boolConnected = True
        End If
    Wend
    Err.Clear
    On Error GoTo 0
End Sub

Open in new window

0

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
t3nguAuthor Commented:
So far this solved my problem!! but only time will tell :) THANKS!!!
0
t3nguAuthor Commented:
One more thing... How can I set a default printer with this script? I used to use:
net.SetDefaultPrinter \\serverName\shareName
 
0
RobSampsonCommented:
SetDefaultPrinter is correct, but again, we'll make it try a few times....

Regards,

Rob.
MapPrinter "\\ford\blue4100"
MapPrinter "\\ford\Royal1RX"
MapPrinter "\\ford\Royal2"
MapPrinter "\\ford\Green1RX"
MapPrinter "\\ford\Green2"
MapPrinter "\\ford\Mid1"
MapPrinter "\\ford\Mid2RX"
 
SetDefaultPrinter "\\ford\Green2"
 
Sub MapPrinter(strPrinter)
    On Error Resume Next
    Set objNetwork = CreateObject("WScript.Network")
    boolConnected = False
    intAttempts = 1
    While boolConnected = False And intAttempts <= 10
        Err.Clear
        objNetwork.AddWindowsPrinterConnection strPrinter
        If Err.Number <> 0 Then
            intAttempts = intAttempts + 1
            WScript.Sleep 2000
        Else
            boolConnected = True
        End If
    Wend
    Err.Clear
    On Error GoTo 0
End Sub
 
Sub SetDefaultPrinter(strPrinter)
    On Error Resume Next
    Set objNetwork = CreateObject("WScript.Network")
    boolConnected = False
    intAttempts = 1
    While boolConnected = False And intAttempts <= 10
        Err.Clear
        objNetwork.SetDefaultPrinter strPrinter
        If Err.Number <> 0 Then
            intAttempts = intAttempts + 1
            WScript.Sleep 2000
        Else
            boolConnected = True
        End If
    Wend
    Err.Clear
    On Error GoTo 0
End Sub

Open in new window

0
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.