Object required: 'WScript'

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

Gemini532Asked:
Who is Participating?
 
WMIFConnect With a Mentor Commented:
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
 
WMIFCommented:
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
 
Gemini532Author Commented:
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
Gemini532Author Commented:
do I need to download something to make this work?  I have windows 2000
0
 
Gemini532Author Commented:
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
 
Gemini532Author Commented:
this code is from the link you sent me.. YZlat ... what did I do wrong?
0
 
WMIFCommented:
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
 
Gemini532Author Commented:
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
 
WMIFCommented:
that timeout is from the default timeout setting in iis.  you can override it on this page.

server.settimeout = #ofseconds
0
 
Gemini532Author Commented:
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
 
WMIFCommented:
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
 
Gemini532Author Commented:
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
 
WMIFCommented:
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
 
Gemini532Author Commented:
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
 
WMIFCommented:
>>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
 
WMIFCommented:
once we have the script ready, ill help you create a scheduled task.  you have access to sign onto the server right?
0
 
Gemini532Author Commented:
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
 
WMIFCommented:
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
 
Gemini532Author Commented:
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
 
Gemini532Author Commented:
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
 
Gemini532Author Commented:
I get an error from the first line of code in teh sendEmail.vbs page.  
0
 
Gemini532Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.