我有一个在我的服务器上运行的 vbscript,并在将文件添加到某个目录时通过 telnet 发送电子邮件。该脚本持续运行,但是如果我没有通过 RemoteDesktop 登录,它将不会执行 telnet 命令。
任何人都可以建议一种在我未登录时执行此脚本的方法吗?
Option Explicit
Dim fso, count, src, folder, file, ncount, cloner
Set fso = CreateObject("Scripting.FileSystemObject")
Set cloner = CreateObject("WScript.Shell")
src = "F:/serverfolders/public/camera"
Set folder = fso.GetFolder(src)
count = 0
For Each file In folder.files
If LCase(fso.GetExtensionName(file)) = "mp4" Then
count = count + 1
End If
Next
ncount = count
WScript.Echo "Initial Count: " & count
Do
count = 0
For Each file In folder.files
If LCase(fso.GetExtensionName(file)) = "mp4" Then
count = count + 1
End If
If LCase(fso.GetExtensionName(file)) = "x" Then Exit DO
Next
if count > ncount then
Call Alarm()
ncount = count
End If
WScript.Sleep 10000
Loop
Sub Alarm
cloner.run"cmd",1,false
WScript.Sleep 1000
cloner.SendKeys"telnet smtp.1and1.com 587"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.AppActivate "telnet smtp.1and1.com"
WScript.Sleep 1000
cloner.SendKeys"EHLO ****.com"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"auth login"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"password"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"password2"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"MAIL FROM: ****.com"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"RCPT TO: ****.com"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"DATA"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"Subject:Motion Alarm Detected"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"Motion Alarm Detected"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"."
cloner.SendKeys("{Enter}")
WScript.Sleep 2000
cloner.SendKeys"quit"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys("{Enter}")
WScript.Sleep 10000
End Sub