Ping Script Problem - vbscript
Frage zu meinem Programm!
Hallo,
habe ein kleines Programm geschrieben, was es mir ermöglichen soll einen Computer alle 2 Sekunden anzupingen, dies in einer TXT zu speichern. Nun zu meinem Problem ich versuche grad, dass wenn der PC offline ist mir eine eMail zusenden zulassen. Das Problem ist nun ich will nicht alle 2 Sekunden eine email sondern nur einmal.
In meinem Programm ist ein Fehler, es kommt immer Objekt erforderlich [string: "ON"]
Vllt. kann ja jemand mal drüber schauen und mir eventuell helfen.
Danke schonmal für die hilfe.
Gruß,
m0nstar
habe ein kleines Programm geschrieben, was es mir ermöglichen soll einen Computer alle 2 Sekunden anzupingen, dies in einer TXT zu speichern. Nun zu meinem Problem ich versuche grad, dass wenn der PC offline ist mir eine eMail zusenden zulassen. Das Problem ist nun ich will nicht alle 2 Sekunden eine email sondern nur einmal.
In meinem Programm ist ein Fehler, es kommt immer Objekt erforderlich [string: "ON"]
Vllt. kann ja jemand mal drüber schauen und mir eventuell helfen.
PingForever strHost, strFile
Sub PingForever(strHost, outputfile)
Dim Output, Shell, strCommand, ReturnCode
Set Output = CreateObject("Scripting.FileSystemObject").OpenTextFile(outputfile, 8, True)
Set Shell = CreateObject("wscript.shell")
strCommand = "ping -n 1 -w 300 " & strHost
SET FLAG0 = "ON"
While(True)
ReturnCode = Shell.Run(strCommand, 0, True)
If ReturnCode = 0 Then
Output.WriteLine Date() & " - " & Time & " | " & strHost & " - ONLINE"
SET FLAG0 = "ON"
Else
Output.WriteLine Date() & " - " & Time & " | " & strHost & " - OFFLINE"
IF FLAG0 = "ON" THEN
SET FLAG0 = "OFF"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "test@test.com"
objEmail.To = "test@test.com"
objEmail.Subject = "PC " & strHost & " nicht erreichbar"
objEmail.Textbody = strText
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"smtpip"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
END IF
End If
Wscript.Sleep 2000
Wend
End Sub
Danke schonmal für die hilfe.
Gruß,
m0nstar
Please also mark the comments that contributed to the solution of the article
Content-Key: 145034
Url: https://administrator.de/contentid/145034
Printed on: April 23, 2024 at 12:04 o'clock
2 Comments
Latest comment