SpeedTest_Hackoo_Ookla.bat
SpeedTest Script Written by Hackoo And Powered by Ookla
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | <# : Batch Script Section
@rem # The previous line does nothing in Batch, but begins a multiline comment block in PowerShell. This allows a single script to be executed by both interpreters.
@echo off
Title SpeedTest Script Written by Hackoo And Powered by Ookla 2022 & Mode 100,25
@REM OPEN CMD WINDOW MAXIMIZED
@REM IF NOT "%1"=="MAX" START /MAX CMD /D /C "%~0" MAX & GOTO :EOF
cd "%~dp0" & echo %~nx0>"%temp%\MyScriptName.txt"
Color 1B & echo( & Echo(
Echo( Please Wait ... Loading script is in Progress ...
Powershell -executionpolicy bypass -Command "Invoke-Expression $([System.IO.File]::ReadAllText('%~f0'))"
EndLocal
pause
goto:eof
#>
# Powershell Script Section begin here...
# Here we execute our powershell commands...
cls
# https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-win64.zip
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
if($OS_Architecture -eq 'x86')
{
write-host 'Your System is 32-bit. Sorry ! This Program is incompatible under this System !' -fore Red
break
}
else
{
############# Playing Music in Background just for relax and have fun #################
Add-Type -assemblyName PresentationFramework
Function Start-Music {
$code = {
$Radios_Stations_Array = @(
"http://retro.dancewave.online/retrodance.mp3",
"http://www.leeholmes.com/projects/ps_html5/background.mp3",
"http://radio.mosaiquefm.net:8000/mosagold",
"http://radio.mosaiquefm.net:8000/mosadj",
"https://stream.initialradio.fr:8443/djbuzz-192k.mp3",
"http://audio1.maxi80.com"
)
$MyShuffledList = $Radios_Stations_Array | Sort {Get-Random}
$url = $MyShuffledList[1]
$player = New-Object -ComObject 'MediaPlayer.MediaPlayer'
$player.Open($url)
$player
}
$script:ps = [PowerShell]::Create()
$script:player = @($ps.AddScript($code).Invoke())[0]
}
#######################################################################################
Function Stop-Music
{
if ($script:player -ne $null)
{
$script:player.Stop()
Remove-Variable -Name player -Scope script
}
if ($script:ps -ne $null)
{
$script:ps.Runspace.Close()
$script:ps.Dispose()
Remove-Variable -Name ps -Scope script
}
}
###############################################################################################
# Starting to play music while executing the script
Write-Host " Please Wait a while ... SpeedTest is in progress ..." -Fore Yellow
Start-Music
$start_time = Get-Date
###############################################################################################
$Title = "SpeedTest Script Written by Hackoo And Powered by Ookla 2022"
$ErrorActionPreference = "SilentlyContinue"
$Zip_URL = "https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-win64.zip"
$Zip_File = "$env:TEMP\speedtest.zip"
$ExtractPath = "$env:TEMP\SpeedTest"
$SpeedTest_EXE = "$ExtractPath\speedtest.exe"
######################### Create A Shortcut to this Script on Desktop #########################
$MyScriptName = GC "$Env:Temp\MyScriptName.txt"
$MyPath = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($pwd,"$MyScriptName"))
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Home\Desktop\SpeedTest.lnk")
$Shortcut.TargetPath = "$MyPath"
$Shortcut.IconLocation = "$SpeedTest_EXE"
$Shortcut.WorkingDirectory = "$([System.IO.Path]::GetFullPath([System.IO.Path]::Combine($pwd,'')))"
$Shortcut.Description = "$Title"
$Shortcut.HotKey = "CTRL+ALT+S"
$Shortcut.Save()
###############################################################################################
# Check if file does not exists , we download and unzip it
if (-not(Test-Path -Path "$Zip_File" -PathType Leaf)) {
Try{$Download = (New-Object System.Net.WebClient).DownloadFile("$Zip_URL","$Zip_File")}
catch {write-host "$_.Exception.Message" -fore Red;Stop-Music;Break;}
unzip "$Zip_File" "$ExtractPath"
}
# Check if file SpeedTest.exe does exists
if (Test-Path -Path "$SpeedTest_EXE" -PathType Leaf) {
$Speedtest = & "$SpeedTest_EXE" --format=json --accept-license --accept-gdpr
$Speedtest | Out-File "$ExtractPath\Last.txt" -Force
$Speedtest = $Speedtest | ConvertFrom-Json
}
[PSCustomObject]$SpeedObject = @{
SSID = (get-netconnectionProfile).Name
ComputerName = $($env:computername)
UserName = $($env:username)
TimeStamp = Get-Date -F "dd/MM/yyyy HH:mm:ss" $Speedtest.timestamp
Downloadspeed = [math]::Round($Speedtest.download.bandwidth / 1000000 * 8, 2)
Uploadspeed = [math]::Round($Speedtest.upload.bandwidth / 1000000 * 8, 2)
Packetloss = [math]::Round($Speedtest.packetLoss)
ISP = $Speedtest.isp
Location = $Speedtest.server.location
Country = $Speedtest.server.Country
ExternalIP = $Speedtest.interface.externalIp
InternalIP = $Speedtest.interface.internalIp
MACAddr = $Speedtest.interface.macAddr
VPN = $Speedtest.interface.isVpn
ServerName = $Speedtest.server.name
UsedServer = $Speedtest.server.host
URLResult = $Speedtest.result.url
Jitter = [math]::Round($Speedtest.ping.jitter)
Latency = [math]::Round($Speedtest.ping.latency)
}
cls
$LogFile = $($SpeedObject.SSID)+"_"+$($env:computername)+"_"+$($env:username)+"_"+"SpeedTest_Results.txt"
$SpeedObject | ConvertTo-Json | Out-File ".\$LogFile" -Append
$SpeedObject
$Elapsed_Time = "$((Get-Date).Subtract($start_time).Minutes) Minutes(M) : $((Get-Date).Subtract($start_time).Seconds) Secondes(s)"
$shell = new-object -comobject "WScript.Shell"
$Answer = $shell.popup("Running Script Time Taken is : $Elapsed_Time `r`nDo you want to launch the result with your default browser ?",0,"$Title",4+32+4096)
If ($Answer -eq 6) {
Write-Host "OK We are Starting the result with your default browser !" -ForegroundColor Yellow -BackgroundColor Blue
ii ".\$LogFile"
Start $SpeedObject.URLResult
$PS_Version=$PSversionTable.PSVersion.Major
If ($PS_Version -ge 2) {$SpeedObject | OGV -Title $Title -Wait}
}
else {
Write-Host "Script Aborted !" -ForegroundColor Yellow -BackgroundColor Blue
ii ".\$LogFile"
}
Stop-Music
}
|