Link to home
Start Free TrialLog in
Avatar of bluematter
bluematter

asked on

WScript Error

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
%>
Avatar of hongjun
hongjun
Flag of Singapore image

Try this

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

hongjun
Avatar of bluematter
bluematter

ASKER

Now have got error

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[string: "\\Server\Printer"]'
/printer.asp, line 3
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
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
%>
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
Same Error...... Bugger.... ;o(

(0x80070709)
/printer.asp, line 4
How could I check to see if the Wscript object was installed on the server?
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
I get the "Unable to install printer at this time."
And the server and printer is available.
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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