?
Solved

Need Help With Error Code 8007007B on VB Script

Posted on 2008-11-05
5
Medium Priority
?
3,163 Views
Last Modified: 2012-05-05
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)
0
Comment
Question by:t3ngu
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 22889453
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
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 22889458
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
 
LVL 1

Author Closing Comment

by:t3ngu
ID: 31513564
So far this solved my problem!! but only time will tell :) THANKS!!!
0
 
LVL 1

Author Comment

by:t3ngu
ID: 22889771
One more thing... How can I set a default printer with this script? I used to use:
net.SetDefaultPrinter \\serverName\shareName
 
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22889826
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question