t3ngu
asked on
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.Netw ork")
net.AddWindowsPrinterConne ction "\\ford\blue4100"
net.AddWindowsPrinterConne ction "\\ford\Royal1RX"
net.AddWindowsPrinterConne ction "\\ford\Royal2"
net.AddWindowsPrinterConne ction "\\ford\Green1RX"
net.AddWindowsPrinterConne ction "\\ford\Green2"
net.AddWindowsPrinterConne ction "\\ford\Mid1"
net.AddWindowsPrinterConne ction "\\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)
This is my script:
Dim net
Set net = CreateObject("WScript.Netw
net.AddWindowsPrinterConne
net.AddWindowsPrinterConne
net.AddWindowsPrinterConne
net.AddWindowsPrinterConne
net.AddWindowsPrinterConne
net.AddWindowsPrinterConne
net.AddWindowsPrinterConne
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So far this solved my problem!! but only time will tell :) THANKS!!!
ASKER
One more thing... How can I set a default printer with this script? I used to use:
net.SetDefaultPrinter \\serverName\shareName
net.SetDefaultPrinter \\serverName\shareName
SetDefaultPrinter is correct, but again, we'll make it try a few times....
Regards,
Rob.
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
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.
Open in new window