Jump to content

Very simple pinger ?


Recommended Posts

I have this .bat file

@ECHO OFF
set IPADDRESS=192.168.1.101
set INTERVAL=60
:PINGINTERVAL

ping %IPADDRESS% -n 1
if errorlevel 1 echo %date% %time% >> c:\pinger\pinger-failurelog.txt

timeout %INTERVAL%
GOTO PINGINTERVAL

Which works fine. In Windows Task Scheduler, I just create a new task, choose this .bat file as action, it runs and produce the log file.

However, I don't want the command prompt to be visible with the 60 sec countdown etc.

I simply want to make an exe from a AutoIt script, and run that instead in the task. Then there won't be a cmd window at all, correct? There will only be an icon on task bar if it runs.

How to achieve this?

Thanks

Link to comment
Share on other sites

Compile it.  Run it from DOS console.  

#AutoIt3Wrapper_Change2CUI=y
#include <Date.au3>

HotKeySet("+{END}", _Exit) ; shift-end

Local Const $sAddress = "www.google.com", $iTimeOut = 60
Local $iResult

While True
  $iResult = Ping($sAddress, 1000)
  ConsoleWrite($iResult & " msec" & @CRLF)
  If @error Then FileWriteLine("Error.log", "Error " & @error & " @ " &_Now())
  Sleep($iTimeOut * 1000)
WEnd

Func _Exit()
  Exit
EndFunc

 

Link to comment
Share on other sites

8 hours ago, Nine said:

Compile it.  Run it from DOS console.  

#AutoIt3Wrapper_Change2CUI=y
#include <Date.au3>

HotKeySet("+{END}", _Exit) ; shift-end

Local Const $sAddress = "www.google.com", $iTimeOut = 60
Local $iResult

While True
  $iResult = Ping($sAddress, 1000)
  ConsoleWrite($iResult & " msec" & @CRLF)
  If @error Then FileWriteLine("Error.log", "Error " & @error & " @ " &_Now())
  Sleep($iTimeOut * 1000)
WEnd

Func _Exit()
  Exit
EndFunc

 

But i dont want to run a cmd prompt... or at least hide it completely

Link to comment
Share on other sites

Hiding the cmd prompt requires running it as the "system" user versus any other account. Slipped my mind until you mentioned it and I tested it. :>

Nine's solution is solid. I especially like the hotkey to terminate it. 

 

Screenshot 2022-07-28 094241.png

Edited by rsn
Image
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...