Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / programming / Internet

Internet speed and Wi-Fi strength tester with a BAT file and Powershell

0.00/5 (No votes)
14 Oct 2024CPOL1 min read 3K  
On Windows, a BAT file can run a powershell script to report your wi-fi strength percentage and internet speed.
Moving a laptop around your house or office can have a significant impact on the quality of your wi-fi signal and internet accessibility. Using a combination of a BAT file and Powershell, we can put together a rudimentary script to report on wi-fi strength and internet speed every X number of seconds.

Introduction

Moving a laptop around your house or office can have a significant impact on the quality of your wi-fi signal and internet accessibility. Using a combination of a BAT file and Powershell, we can put together a simple script to report on wi-fi strength as a percentage and internet speed every X number of seconds.

Using the code

1. Create a new folder "internettest" on the C:\ drive.

2. Create a new file called InternetTest.bat in the "internettest" folder.

3. Using a text editor (notepad), insert the following line into the InternetTest.bat file:

BAT
powershell -ExecutionPolicy bypass c:\internettest\InternetTest.ps1

4. Create a new file called InternetTest.ps1 in the "internettest" folder.

5. Using a text editor (notepad), insert the following into the InternetTest.ps1 file:

PowerShell
echo "wi-fi strength monitor"

1..4 | % {

    (netsh wlan show interfaces) -Match '^\s+Signal' -Replace '^\s+Signal\s+:\s+',''

    start-sleep 2

}

echo ""

echo "internet speed test"

1..4 | % {

    Function Get-InternetSpeed{

        $TestFile = 'http://speedtest.tele2.net/10MB.zip'

        $TempFile = Join-Path -Path $env:TEMP -ChildPath 'testfile.tmp'

        $WebClient = New-Object Net.WebClient

        $TimeTaken = Measure-Command { $WebClient.DownloadFile($TestFile,$TempFile)} | Select-Object -ExpandProperty TotalSeconds

        $Speed = (10 / $TimeTaken) * 8

        $Message = "{0:N2} Mbit/Sec" -f ($Speed)

        echo $Message

    }

    Get-InternetSpeed

    start-sleep 5

}

start-sleep 120

 

6. Save both files.

7. Open a Window command prompt as an administrator and navigate to the path C:\internettest using the DOS command:
cd C:\internettest

8. On the command prompt, enter:
InternetTest.bat 

9. Press <ENTER> and the console will report the wi-fi strength and internet speed.

 

Points of Interest

In the code, "1..4" is a loop that performs the test 4 times. In your testing, you can increase or decrease the number of times to loop through the tests. The start-sleep command pauses the specified number of seconds between tests. This can also be increased or decreased.

History

--

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)