Solved

Object required: 'WScript'

Posted on 2006-11-16
23
4,021 Views
Last Modified: 2008-01-09
I get the following error, which trying to get the computer to sleep:

Microsoft VBScript runtime error '800a01a8'

Object required: 'WScript'

/oip/WriteToDBEmail.asp, line 228

I'm using the WScript Object to get the computer to sleep, but it's giving me an error can you help?

CODE:
<!--#include file="connection.asp" -->
<%
      
sql="SELECT * FROM EmailList"
Set RS=Conn.Execute(sql)
Do while not RS.EOF
      intCount=intCount+1
      
      aspID=RS("ID")
      aspFN=RS("FirstName")
      aspLN=RS("LastName")
      aspEmail=RS("Email")
      
            set objMail=Server.CreateObject("Jmail.SMTPMail")
            if Err.number <> 0 then
                  Response.Write("<BR>Error Sending Mail: Contact CSC<BR>")
            else
                  objMail.ServerAddress = "0.0.0.0"      

                  'Angie H. -- email to everyone in the database address in the form
                  objMail.AddRecipient("" & aspEmail & "")
                  objMail.Sender = "fake@fake.com"
                  objMail.Subject="New Entry"
                  objMail.Body="Email Body"

'This code sends out 50 emails at a time and then goes to sleep...  zzzZZZzzz
      if intCount mod 50 = 0 then

            
'**********Sleep Code Goes here  zzzZZZZZzzz***********
   
set WshShell = WScript.CreateObject("WScript.Shell")
dim num
num=1
do while not num=5
       WshShell.Sleep 1000  '<--------not WScript
   num=num+1
   response.write num
   response.write "<br>"
loop
'**********End Sleep Code Goes here  zzZZZZzzz***********
      end if
      
      objMail.Execute  '*********Send Email*******
                  
                  
'Angie H. -- To show the names of each person receiving this email, uncomment the line below:
      Response.write aspFN & " " & aspLN & " (" & aspEmail & ")"
      Response.Write "<br>"



      end if
      set objMail=nothing
            
      RS.MoveNext
Loop

0
Comment
Question by:Gemini532
  • 13
  • 9
23 Comments
 
LVL 22

Expert Comment

by:WMIF
ID: 17957915
set WshShell = WScript.CreateObject("WScript.Shell")

that line should not have the "wscript" there.  either nothing or "server".

set WshShell = CreateObject("WScript.Shell")
set WshShell = server.CreateObject("WScript.Shell")
0
 

Author Comment

by:Gemini532
ID: 17957940
Now I got the following error:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'WshShell.Sleep'

/oip/WriteToDBEmail.asp, line 236
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17957966
0
 

Author Comment

by:Gemini532
ID: 17957993
do I need to download something to make this work?  I have windows 2000
0
 

Author Comment

by:Gemini532
ID: 17958048
I changed my code to:

if intCount mod 50 = 0 then
      
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Sleep(5000)

end if

And I got this error:
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Sleep'

/oip/WriteToDBEmail.asp, line 236
0
 

Author Comment

by:Gemini532
ID: 17958068
this code is from the link you sent me.. YZlat ... what did I do wrong?
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17958270
what if you use server.createobject() there?

you can try this code instead:
http://classicasp.aspfaq.com/general/how-do-i-make-my-asp-page-pause-or-sleep.html
0
 

Author Comment

by:Gemini532
ID: 17958612
Hi WMIF, I took ur adivce and now it seems to be working because it sends out 50 emails then it goes to sleep for 10 seconds as seen from:
Response.Write(now & "<p>")
    conn.Execute sql,,129
    Response.Write(now & "<p>")

shows up as:
50 emails

11/16/2006 1:33:07 PM

11/16/2006 1:33:17 PM

50 emails
etc...

But after that it times out and gives me the servertimeour error:
Active Server Pages error 'ASP 0113'

Script timed out

/oip/WriteToDBEmail.asp

The maximum amount of time for a script to execute was exceeded. You can change this limit by specifying a new value for the property Server.ScriptTimeout or by changing the value in the IIS administration tools.


Now I've been testing this for the past 2 hours sending our 800 emails every time I test the application, I'm thinking it's possible that by now the email server is completely backed up... Would something like this give me a timeour error?  Or is there definitely something wrong with the code, for instance, the computer is not sleeping long enough, or not getting enough rest...hehe
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17958707
that timeout is from the default timeout setting in iis.  you can override it on this page.

server.settimeout = #ofseconds
0
 

Author Comment

by:Gemini532
ID: 17958937
if I override it, is that a security risk?

Server.ScriptTimeout = 360  
Is doing this in any way maki ng the page NOT secure?  Someone told me that increasing the timeout script is a security risk, did they mean in IIS?  
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17958977
its not a security risk at all.  all it does is allow a script to run longer.  it would be a bad thing to do in the iis panel because that lets all of your pages run for a longer time.  that can eatup server resources, but since you know that this page is alright you can just extend the timeout for this page only with that line above.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Gemini532
ID: 17959061
I really don't understand why the computer would time out even after it has time to sleep for like 10 seconds...
I thought the idea of sleeping was that it would cut the script and the computer will think that the script is only 30 seconds or so... then the next scrips it only 30 seconds, so there's no reason to timeout, because the scripts are short...

I did notice that only AFTER all the emails are sent, the next page shows up.  There are 2 pages one is called 1.asp and one is 2.asp
when submitting 1.asp, 2.asp shows up but only after about 5 minutes...
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17959140
the sleep doesnt divide the scripts at all.  you are loading the page and its all done in one process.  asp isnt a very advanced language.  what i would suggest is converting your code to a .vbs file, and then setting up a scheduled task on the server to run through the code every 10 mins, whatever you would like.
0
 

Author Comment

by:Gemini532
ID: 17959340
You mean if I save just the vb script code in a .vbs file then call it from my ASP page, it could work
but I don't know how to set up a scheduled task on the server to run through the code every 10 mins
Could you walk me through it... It shouds exactly what I'm looking for...

So making the computer sleep is just ADDING time on the process instead of deleting... As it is right now, the code is actually working against me...
isn't it?
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17959438
>>So making the computer sleep is just ADDING time on the process instead of deleting... As it is right now, the code is actually working against me...
isn't it?

exactly.



>>You mean if I save just the vb script code in a .vbs file then call it from my ASP page, it could work

what i was suggesting will have nothing to do with your asp pages.  the only similarity is that its written in vbscript.  there are things you will want to remove form the code in order to run this automated.  lets save a copy of this page as a .vbs file and start working.  you do not want anything from the asp related processes because a vbs doesnt recognize it.  so remove all request and response occurances.  also any server.[something] need to be removed.  unless its a createobject which you would just remove the "server." part and leave the create object.
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17959444
once we have the script ready, ill help you create a scheduled task.  you have access to sign onto the server right?
0
 

Author Comment

by:Gemini532
ID: 17959739
Ok, I created a new page called Sleep.vbs

This is the code in it.  Now I can include this page in the page where it came from with this code:
<!--#include file="sleep.vbs" -->  but I won't until after we create those scheduled tasks on the server...
I don't have a connection with the server, but a co-worker who does, said that if I tell her what to do, we can do it together in the server room...  :)
Is this .vbs page OK?  This code worked for me when it was in the original page...


'Angie H. -- This page is created to stop the browser and make it sleep after it sends out 50 emails then send the rest of the emails...
'Add the Connection string
Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "fake","fake","fake"  


if intCount mod 50 = 0 then
   dim sleep
   sleep = 10
      
    conn.commandTimeout = sleep1 + 5   ' make sure timeout doesn't expire!
 
  sql = "WAITFOR DELAY '00:00:" & right(clng(sleep1),2) & "'"          ' if you need more than 59 seconds, you will need to adjust the SQL:
 
   Response.Write(now & "<p>")
   conn.Execute sql,,129
  Response.Write(now & "<p>")
end if

'End Connection
Conn.Close
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17959887
i was meaning to take the email processing off of an asp page and put that into the vbs file.  what you are trying to do with a sleep file is still going to extend the page load past your timeout setting.
0
 

Author Comment

by:Gemini532
ID: 17980054
I saved the entire email code in a file called SendEmail.vbs
and then I used this include statment to call it:
<!--#include file="SendEmail.vbs" -->
But it's incorrect.  All this did, was print on the screen the code in the SendEmail.vbs file
0
 

Author Comment

by:Gemini532
ID: 17980087
I tried this but it didn't work either:
<!--#include file="connection.asp" -->    
<SCRIPT LANGUAGE="VBScript" SRC="SendEmail.vbs"></SCRIPT>

The code for the connection works. but the code for the sendEmail.vbs page does not work...
0
 

Author Comment

by:Gemini532
ID: 17980100
I get an error from the first line of code in teh sendEmail.vbs page.  
0
 

Author Comment

by:Gemini532
ID: 17980141
This is my code in the sendEmail.vbs page:

response.write "<font face='Arial'>Your project has been added.<br>"
intCount=0
      
      sql="SELECT * FROM EMailList"

Set RS=Conn.Execute(sql)
Do while not RS.EOF
      intCount=intCount+1
      
      aspID=RS("ID")
      aspFN=RS("FirstName")
      aspLN=RS("LastName")
      aspEmail=RS("Email")
      
      
            ' JMAIL CODE ADDED 7-19-2001 BY MICHAEL LABMAN TO REPLACE CDONTS
            set objMail=Server.CreateObject("Jmail.SMTPMail")
            if Err.number <> 0 then
                  Response.Write("<BR>Error Sending Mail: Contact CSC<BR>")
            else
                  objMail.ServerAddress = "00.00.00.00"      

                  'Angie H. -- email to everyone in the database address in the form
                  objMail.AddRecipient("" & aspEmail & "")
                  objMail.Sender = "fake@fake.com"
                  objMail.Subject="New Entry"
                  
            objMail.Body="Email Body"
            '**********************************************************************************
            'Angie H. (11/16/2006) -- 'This code makes the computer sleep after sending 50 emails
            if intCount mod 50 = 0 then
                  dim sleep
                  sleep = 10
                  
                  conn.commandTimeout = sleep + 5   ' make sure timeout doesn't expire!
             
                  sql = "WAITFOR DELAY '00:00:" & right(clng(sleep),2) & "'"          ' if you neede more than 59 seconds, you will need to adjust the SQL:
             
                  Response.Write(now & "<p>")
                  conn.Execute sql,,129
                  Response.Write(now & "<p>")
            end if
            '**********************************************************************************

      objMail.Execute  'Send Email
      
      'Angie H. -- To show the names of each person receiving this email, uncomment the line below:
      Response.write aspFN & " " & aspLN & " (" & aspEmail & ")"
      Response.Write "<br>"

      end if
      set objMail=nothing
            
      RS.MoveNext
Loop
RS.Close
Conn.Close
0
 
LVL 22

Accepted Solution

by:
WMIF earned 500 total points
ID: 17981470
you are still trying to add this code to a page.  that page has to be executed and sleeping after 50 emails does not break up the page.  the vbs file should be a stand alone script that will not sleep, it just processes 50 and stops.  then a task scheduler will run it again at a predetermined time.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

13 Experts available now in Live!

Get 1:1 Help Now