Solved

WScript Error

Posted on 2001-09-15
12
16,629 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
Comment Utility
Try this

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

hongjun
0
 

Author Comment

by:bluematter
Comment Utility
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
Comment Utility
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
 

Author Comment

by:bluematter
Comment Utility
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
Comment Utility
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
Comment Utility
Same Error...... Bugger.... ;o(

(0x80070709)
/printer.asp, line 4
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

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

Expert Comment

by:hongjun
Comment Utility
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
Comment Utility
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
Comment Utility
Do you have permission to install the printer?

hongjun
0
 

Author Comment

by:bluematter
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now