每30分钟执行一次vbs [英] execute a vbs every 30 minutes
问题描述
我想要展望每30分钟发送一次服务器实时。有没有办法我可以在当前的代码或通过批处理文件?使计划的任务不可用,没有第三方软件
set objOutlook = CreateObject(Outlook.Application)
设置objMail = objOutlook.CreateItem(0)
strMessage =Test
ON ERROR RESUME NEXT
With objMail
.From =email
.To =email
.Subject =Test
.Body = strMessage
.Save
end with
objMail。 OriginatorDeliveryReportRequested = True
objMail.Display
objMail.Send
WScript.quit
使用VBScript进行睡眠的示例:
:waittime = 30 * 60 * 1000
do
'在这里插入代码
WScript.Sleep(waittime)
loop
哦,摆脱WScript.Quit语句,这将...退出你的脚本! / p>
编辑
另一种做法和集成消息框正在使用 WshShell.Popup
:
do
'在这里插入代码
设置WshShell = CreateObject(WScript.Shell)
如果WshShell.Popup(发送每30分钟发一封邮件& vbNewLine& _
按取消停止或确定立即发送邮件,_
waittime,自动邮件发件人,1或32或4096)= 2然后
退出执行
end if
loop
此代码段将每次执行代码 waittime
,当按下取消按钮时,它将停止,当 OK
被按下时,它将立即执行代码。 p>
I want outlook to email a server every 30 mins in real time. is there a way i can do it in this current code or via batch file? making a scheduled task is unavailable and no third party software
set objOutlook = CreateObject( "Outlook.Application" )
set objMail = objOutlook.CreateItem(0)
strMessage = "Test"
ON ERROR RESUME NEXT
With objMail
.From = "email"
.To = "email"
.Subject = "Test"
.Body = strMessage
.Save
end with
objMail.OriginatorDeliveryReportRequested = True
objMail.Display
objMail.Send
WScript.quit
An example of sleeping with VBScript:
Dim waittime : waittime = 30 * 60 * 1000
do
' Insert your code here
WScript.Sleep(waittime)
loop
Oh, and get rid of the WScript.Quit statement, that will... quit your script!
EDIT
Another way to do it and integrate the messagebox is using the WshShell.Popup
:
do
' Insert your code here
Set WshShell = CreateObject("WScript.Shell")
If WshShell.Popup ( "Sending a mail every 30 minutes" & vbNewLine & _
"Press Cancel to stop or OK to send a mail right now.", _
waittime, "Automatic mail sender", 1 or 32 or 4096) = 2 Then
exit do
end if
loop
This snippet will execute the code every waittime
, it stops when the Cancel button is pressed and it will execute the code immediately when OK
is pressed.
这篇关于每30分钟执行一次vbs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!