Gemini532
asked on
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.CreateObjec t("Jmail.S MTPMail")
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("WScr ipt.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
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.CreateObjec
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("WScr
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
ASKER
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
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'WshShell.Sleep'
/oip/WriteToDBEmail.asp, line 236
ASKER
do I need to download something to make this work? I have windows 2000
ASKER
I changed my code to:
if intCount mod 50 = 0 then
Dim WshShell
Set WshShell = CreateObject("WScript.Shel l")
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
if intCount mod 50 = 0 then
Dim WshShell
Set WshShell = CreateObject("WScript.Shel
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
ASKER
this code is from the link you sent me.. YZlat ... what did I do wrong?
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
you can try this code instead:
http://classicasp.aspfaq.com/general/how-do-i-make-my-asp-page-pause-or-sleep.html
ASKER
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
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
that timeout is from the default timeout setting in iis. you can override it on this page.
server.settimeout = #ofseconds
server.settimeout = #ofseconds
ASKER
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?
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?
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.
ASKER
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...
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...
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.
ASKER
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?
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?
>>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.
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.
once we have the script ready, ill help you create a scheduled task. you have access to sign onto the server right?
ASKER
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 .Connectio n")
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
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
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
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.
ASKER
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
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
ASKER
I tried this but it didn't work either:
<!--#include file="connection.asp" -->
<SCRIPT LANGUAGE="VBScript" SRC="SendEmail.vbs"></SCRI PT>
The code for the connection works. but the code for the sendEmail.vbs page does not work...
<!--#include file="connection.asp" -->
<SCRIPT LANGUAGE="VBScript" SRC="SendEmail.vbs"></SCRI
The code for the connection works. but the code for the sendEmail.vbs page does not work...
ASKER
I get an error from the first line of code in teh sendEmail.vbs page.
ASKER
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.CreateObjec t("Jmail.S MTPMail")
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
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.CreateObjec
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
that line should not have the "wscript" there. either nothing or "server".
set WshShell = CreateObject("WScript.Shel
set WshShell = server.CreateObject("WScri