New
#51
So my suggested revised batch file is this.
It's simpler than I thought because there is only a need to have a single looping control variable not two.
I've remarked out the Pause line at the end for you.
You'll still want to item it to check that it is completing within the 1 minute TS interval.
Code::: Initialisation Prompt $g Set WWWConnection=Off Set "OutputFolder=%Temp%" Set "OutputFile=%Random%-WWWConnection-TestResults" Set /a TestCounter=0 :DoTheTest :: Run test every 10 secs to use up the 1 minute between TS starting this task again. TimeOut /T 10 Set /a TestCounter=%TestCounter%+1 powershell -Command "Invoke-WebRequest http://www.msftconnecttest.com/connecttest.txt -OutFile '%OutputFolder%\%OutputFile%'" dir "%OutputFolder%\%OutputFile%" If %ErrorLevel% GTR 0 GoTo RestartAdapter If %ErrorLevel% EQU 0 GoTo RepeatTheTest :: Restart the WiFi network adapter if the internet network connection exists but does not function i.e. no web addresses are working :RestartAdapter ::::: This is your existing PS code for resetting your network adapter powershell.exe restart-netadapter -Name 'Wi-Fi 13' :RepeatTheTest :: Repeat the test if less than a minute has passed i.e. TestCounter < 6 del "%OutputFolder%\%OutputFile%" If TestCounter LSS 6 GoTo DoTheTest :: EndWWWConnectionTest :: Pause at the end during testing - WWWConnection is %WWWConnection% :: The batch file now closes of its own accord :: Notes :: If there is an internet connection, the output file is created :: If there is no internet connection, the output file is initially created but is deleted by powershell when it generates its failure response. :: If you were to run this non-minimised, you would see some red text as it failed to find the www.msftconnecttest.com/connecttest.txt file
Denis