Solved

WScript Error

Posted on 2001-09-15
12
16,636 Views
Last Modified: 2012-05-04
When I try to run this and other WSH scripts I get this error.

Any Idea?

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'WScript'

<%
Set NWPrinter = WScript.CreateObject("WScript.Network")
Set NWPPath = "\\Server\Printer"
NWPrinter.AddWindowsPrinterConnection(NWPPath)
Set rc = NWPrinter.AddWindowsPrinterConnection(NWPPath)
If Not rc then
     WScript.Echo("Unable to install printer at this time.")
End If
NWPrinter.SetDefaultPrinter NWPPath
%>
0
Comment
Question by:bluematter
  • 7
  • 5
12 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 6484743
Try this

<%
Set NWPrinter = Server.CreateObject("WScript.Network")
'''''
%>

hongjun
0
 

Author Comment

by:bluematter
ID: 6484811
Now have got error

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[string: "\\Server\Printer"]'
/printer.asp, line 3
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6484816
How about this?

<%
Set NWPrinter = Server.CreateObject("WScript.Network")
NWPPath = "\\Server\Printer"
Set rc = NWPrinter.AddWindowsPrinterConnection(NWPPath)
If Not rc then
    WScript.Echo("Unable to install printer at this time.")
End If
NWPrinter.SetDefaultPrinter NWPPath

Set NWPrinter = Nothing
%>

hongjun
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:bluematter
ID: 6484862
Now have got a very helpful error.

Error Type:
(0x80070709)
/printer.asp, line 4

<%
Set NWPrinter = Server.CreateObject("WScript.Network")
NWPPath = "\\server\Printer"
Set rc = NWPrinter.AddWindowsPrinterConnection(NWPPath)
If Not rc then
   WScript.Echo("Unable to install printer at this time.")
End If
NWPrinter.SetDefaultPrinter NWPPath

Set NWPrinter = Nothing
%>
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6484872
Try this

<%
Set NWPrinter = Server.CreateObject("WScript.Network")
NWPPath = "\\server\Printer"
If Not NWPrinter.AddWindowsPrinterConnection(NWPPath) then
  WScript.Echo("Unable to install printer at this time.")
End If
NWPrinter.SetDefaultPrinter NWPPath

Set NWPrinter = Nothing
%>

hongjun
0
 

Author Comment

by:bluematter
ID: 6484885
Same Error...... Bugger.... ;o(

(0x80070709)
/printer.asp, line 4
0
 

Author Comment

by:bluematter
ID: 6484887
How could I check to see if the Wscript object was installed on the server?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6485331
How about this?

<%
On Error Resume Next

Set NWPrinter = Server.CreateObject("WScript.Network")
NWPPath = "\\server\Printer"
NWPrinter.AddWindowsPrinterConnection NWPPath
If Err.Count <> 0 Then
    Response.Write "Unable to install printer at this time."
Else
    NWPrinter.SetDefaultPrinter NWPPath
End If

Set NWPrinter = Nothing
%>


hongjun
0
 

Author Comment

by:bluematter
ID: 6485564
I get the "Unable to install printer at this time."
And the server and printer is available.
0
 
LVL 33

Accepted Solution

by:
hongjun earned 50 total points
ID: 6501814
Do you have permission to install the printer?

hongjun
0
 

Author Comment

by:bluematter
ID: 6502188
Yes I had.  I am currently rebulding my 2000 server so I will try it again from a fresh install. Will relpy in a day or two.
0
 

Author Comment

by:bluematter
ID: 6516963
After reinstalling the server and installing WScript 5.6 I tried it again.  
The code to install the printer only work's when running through a VBS file & not via ASP.  I believe this is a limitation to WScript 5.6.  I can use other functions of the OCX ok Like mapping & unmapping network drives viewing network shares etc.

The MSN community is quite good.
http://communities.msn.com/windowsscript
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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