0

I have written a simple batch script (which will be converted to an .exe later) which checks if a server is reached before opening its webpage:

@echo off
ping -n 1 -w 1000 10.###.###.1 | find "TTL=" >nul
if errorlevel 1 (
    msg "%username%" You are not connected via VPN. You have to conect to VPN first!
    if %ERRORLEVEL% NEQ 0 (
        echo You are not connected via VPN. You have to conect to VPN first!
    )
) else (
    ping -n 1 -w 1000 some.server.name | find "TTL=" >nul
    if errorlevel 1 (

        ping -n 1 -w 1000 192.168.###.### | find "TTL=" >nul
        if errorlevel 1 (
            msg "%username%" Couldn't find requested Server. Please contact the administrator!
            if %ERRORLEVEL% NEQ 0 (
                echo Couldn't find requested Server. Please contact the administrator!
            )
        ) else (
            msg "%username%" Connected but using NO-DNS Fallback. Please inform the administrator!
             if %ERRORLEVEL% NEQ 0 (
                echo Connected but using NO-DNS Fallback. Please inform the administrator!
            )
            cmd /c start "" "http://192.168.###.###"
        )
    ) else (
        cmd /c start "" "http://some.server.name"
    )   
)

This works perfect and does what it should.

Anyway in case of failure and the server is not reached for some reason, it still takes some time (I'ld expect 2 seconds but actually it takes up to 9 seconds) until the user gets the message as feedback ... meanwhile he doesn't know, wether the code is doing something.

I wonder if there is any posibility only using batch to display some kind of "Splashscreen" (message/image) only during the pings until it connects or an error message is displayed, letting the user know that the script is running?

I say only using batch because since it is just a kind of "smart" URL Link I would like not to have to put too much effort in this e.g. using java or something like that.

4
  • Why don't you always show the user a "Working..." message before you start pinging and then another one when you're done with either "Success" or "Error"? Oct 18, 2017 at 0:53
  • Possible, but how do I "kill" a message? The problem would be that if it succeeds within 2ms than there still would be the messages displayed .. but I want to display a message or something just during the connection checks
    – derHugo
    Oct 18, 2017 at 6:48
  • Well that depends: how are you showing your messages? Oct 23, 2017 at 12:29
  • Until now by msg or (if it is not installed/available) as fallback by using echo because I noticed msg is not available on Windows Home e.g.
    – derHugo
    Oct 24, 2017 at 4:54

1 Answer 1

0

I didn't find a solution for the "Splash Screen", so I would still be interested in this.

But I've found a workaround which is ok for now by using the -w option for ping and setting a maximal timeout of 1 sec. what is ok for a user to wait.

But I still would prefere the "Splash Screen" way if someone has a solution for this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .