hackoofr

SpeedTest_Hackoo_Ookla.bat

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