Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WScript Error

Posted on 2001-09-15
12
Medium Priority
?
16,659 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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