サーバー上で実行され、ファイルが特定のディレクトリに追加されるたびに telnet 経由で電子メールを送信する vbscript があります。スクリプトは継続的に実行されますが、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