• Still running Windows 7 or earlier? Support for Windows 7 ended on January 14th 2020. Please review the thread here for more details.

can we get data (not raw data)on download speed upload speed using wmic

jraju

Well-known member
Joined
Aug 21, 2017
Posts
144
Hi, I know that there are sites that gives you download speed and upload speed at any point of time and it is actual download speed of the download file from the site.
I know that this information could also be found out using wmic command.
I have checked the wmic commands and the example results in this sysnative website.
I could not find this information.
Could you give me a bat file which gives you the above information on the desktop , always .
I want the speed in mega bytes from the raw speed data available in root/cimv2.
could you send the batch file , so that i get that useful information on my desktop.
i do not want the min and max speed capacity of the network adapter.
only the actual speed in mega bytes.
I could avoid going to speed sites, and get the speed at each time with annoying clicks and avoidable advts.
 
I have not asked any software that could do. What I want is data from using wmic, as I have given in the link. Did you see the link
there are batch files in wmi commands that fetch us data from root/cimv2. I do not mean any software
 
Did you try the download above? It covers your criteria.
I want the speed in mega bytes from the raw speed data available in root/cimv2.
could you send the batch file , so that i get that useful information on my desktop.
i do not want the min and max speed capacity of the network adapter.
only the actual speed in mega bytes.
I could avoid going to speed sites, and get the speed at each time with annoying clicks and avoidable advts.

Also this. How to Test Your Internet Speed from the Command Line

There is a script on this page. Automated Internet Speedtests for Distributed Networks
 
Hi, xro, thanks for the link to script page. How do I execute the script. Do I have to download something more .
Which computer language this script has been written. I have read script words and it seems that you have taken time to locate the script. Thanks for that.
how do i execute it , so that it shows on my desktop all the time. But it does seem that to calculate the speed test, it uses cdn, a new term to point, servers general servers to provide users a stable network connection.
I found the bytesreceived per second and bytessent per second from task manager network tab and also from using wmiexplorer, a gui that gives the result. But what I lack is , it does not tally with the actual download speed.
Or am I missing something.
when you download something, you are getting the rate of bytes increases from 0 to some bytes and if you do not use browsing it stays at 0. I get the total bytes persecond. Should i divide it just by 1024*1024 to get mega bytes speed or should i do something more to get the actual speed.
I think that both the network tab and wmi capture the samething. Normally download upload bytes are not shown in network tab. You have to enable in view column to get this data on your desktop in task bar and for wmi, you have to go to the cimv2 and then query the same.
I just put this bytes in online converters and it gives unbelievable results. I am missing on something.
please say
 
1,048,576 bytes= 1megabyte


As far as the script goes, you'll have to add your parameters and then copy and paste it into an elevated Powershell window.

Or you can run it as is and the errors in red tell you what parameters to change.
 
what should be the extension that I should save the file is the main part of my query.
I think bat files never look like this and so, I asked for the details
 
HI, xro, kindly include the script. I tried to run in powershell , but getting so many redlines , the script itself totally displays as red lines line by line and also tell me how to execute in powershell.
Sorry for the late reply, but my system got corrupted and I had to reinstall windows .
the delay is regretted.. I renamed the script and I tried in powershell and got full line as errors .
I am using windows 7 64 ultimate version.
I just copied all the lines of the script with description lines included, but i get errors .please
 
I think i have to edit the script to include core variables. But i do not know how to .
what is cdn. can I give the google dns open server ip address
which lines are to be changed to change the parameters.
Only advanced programmer know these kind of terms.
If you give a clue, then I may get the result I want
 
it starts with cdn. I am a newbie in programming. If i had known i would not have asked you
 
I am not a programmer but I can follow directions which is what I'd like you to do.

I cannot write the script for you as I don't have your parameters.

Run the script by copying and pasting it into an elevated Powershell prompt. Pay attention to the output sections in red. Read the red output dialogue and change your script accordingly.

The CDN is commented out. Anything after a # is ignored.
 
Hi, xro,

I cannot write the script for you as I don't have your parameters.
You need not write the script. You please say the parameters, which I have to supply. I had not heard s3 bucket for eg.
I could read the script and if parameters , known to me then I wlll try.
thanks anyway
 
Last edited by a moderator:
The variables which you need to set are highlighted in red. If you want to use WMI to test your upload/download speed then you're going to have to provide some of the parameters yourself such as the download and upload endpoints.

Here's a CDN endpoint which you can use: "https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js".

The S3 bucket endpoint is where you upload the files you downloaded from the CDN to, it doesn't have to be an Amazon S3 endpoint, you could change it to another public endpoint you've created yourself, although, it's probably easier to just create an Amazon S3 bucket endpoint since the script has been written with that in mind.

The local download path can simply be your downloads folder, so you could set it to the following: $Env:UserProfile + "\Downloads".

I haven't used WMI very much at all, however, I believe the final two variables can be set to any string as you see fit.

Rich (BB code):
# Authors: Colleen Hutson & Geoffrey Cole
# -------------------------------------------------------------------------------------------------|
# Purpose:
#   - Script is designed to test the down/up rate of a particular device
# Process:
#   - Download speed is determined by downloading files increasing in size from CDN
#   - Upload speed is determined by uploading files increasing in size to an S3 bucket
#   - Final up/down speed rates are saved to custom WMI paths
# -------------------------------------------------------------------------------------------------|
# ------------------------------------------------ #
# Script Variables
# ------------------------------------------------ #
# Calculated download speed
$_avgDownload = 0
# Calculated upload speed
$_avgUpload = 0
# CDN address
$_cdnAddress = <CDN ADDRESS>
# S3 Bucket URL
$s3EndPoint = <S3 BUCKET ENDPOINT>
# Local file path to save downloads to
$_localDownloadPath = <LOCAL PATH TO SAVE DOWNLOADS TO>
# Track up/download failed (1=failed 0=sucess)
$_spFailureTrack = 0
# WMI Namespace
$_wmiNamespace = <CUSTOM WMI NAMESPACE>
# WMI Class
$_wmiClass = <CUSTOM WMI CLASS>
# Silence up/download progress bar, so to not throttle up/download process
$progressPreference = 'silentlyContinue'
# ------------------------------------------------ #
# First calculate the average download speed
# Download is calculated first because the files that are downloaded will be uploaded to calculate upload speed
# For Loop Logic Explanation:
#   - 10 files of known size located at the CDN endpoint
#   - Download, in increasing file size order, all 10 files or as many as possible 15 seconds
# ------------------------------------------------ #
# File path endings
$downloadPaths = "1_5mb", "2_5mb", "5mb", "10mb", "20mb", "25mb", "40mb", "50mb", "75mb", "100mb"
# Creates the file path for downloaded objects if it does not exist.
If (-not(Test-Path -path $_localDownloadPath)) {
    New-Item $_localDownloadPath -type directory -ErrorAction SilentlyContinue | Out-Null
}
# Create lists to store download time and downloaded file sizes to
[System.Collections.ArrayList]$downloadTimes = @()
[System.Collections.ArrayList]$downloadSize = @()
try {
    $index = 0
    # While less than 15 seconds have elapsed and files available, download file of greater size than preceeding one
    For ($startTime = Get-Date; ((Get-Date)-$startTime).TotalSeconds -le 15 -and $index -lt 10; $index++) {
        # File download start time
        $downStart = Get-Date
        # Download file
        Invoke-WebRequest $_cdnAddress/$($downloadPaths[$index]) -OutFile "$_localDownloadPath\$($downloadPaths[$index])"
        # Calculate time to download file and save to list
        $downloadTimes.Add(((Get-Date)-$downStart).TotalSeconds)
        # Calculate size of file downloaded and save to list
        $downloadSize.Add((Get-Item -Path $_localDownloadPath\$($downloadPaths[$index])).Length/1024/1024)
    }
    # Calcaulte average download speed
    $downloadSum = 0
    for ($i=0; $i -lt $downloadTimes.Count; $i++) {
        $downloadSum = $downloadSum + ($downloadSize[$i] / $downloadTimes[$i] * 8)
    }
    $_avgDownload = $downloadSum / $downloadTimes.Count
}
catch {
    $_spFailureTrack = 1
}
# ------------------------------------------------ #
# Second calculate the average upload speed
# For Loop Logic Explanation:
#   - Use files that were downloaded for calculating the average download speed
#   - Upload, in increasing file size order, all files that were downloaded or as many as possible 15 seconds
# ------------------------------------------------ #
try {
    # Get files from SpeedTest folder and sort from smallest to largest file
    $uploadPaths = Get-ChildItem $_localDownloadPath\*mb | Sort-Object -Property Length
    # Create lists to store download time and downloaded file sizes to
    [System.Collections.ArrayList]$uploadSize = @()
    [System.Collections.ArrayList]$uploadTimes = @()
  
    $index = 0
    $index
    # While less than 15 seconds have elapsed and files available, upload file of greater size than preceeding one
    for ($startTime = Get-Date; ((Get-Date)-$startTime).TotalSeconds -le 15 -and $index -lt $uploadPaths.Count; $index++) {
        # Start time for upload
        $upStart = Get-Date
        # Create S3 URL and upload file
        $s3URL = "$s3EndPoint/$env:COMPUTERNAME/$($uploadPaths[$index].Name).txt"
        Invoke-RestMethod -Uri $s3URL -Method Put -InFile $uploadPaths[$index].FullName
        # Calculate time to upload file and save to list
        $uploadTimes.Add(((Get-Date)-$upStart).TotalSeconds)
        $uploadSize.Add($uploadPaths[$index].Length/1024/1024)
    }
  
    # Calculate average upload speed
    $uploadSum = 0
    for ($i=0; $i -lt $uploadTimes.Count; $i++) {
        $uploadSum = $uploadSum + ($uploadSize[$i] / $uploadTimes[$i] * 8)
    }
    $_avgUpload = $uploadSum / $uploadTimes.Count
}
catch {
    $_spFailureTrack = 1
}
# ------------------------------------------------ #
# Third save the up/down speeds to custom WMI Objects
# ------------------------------------------------ #
# Check if wmi namespace exists and create if not
If (Get-WmiObject -Namespace "root\cimv2" -Class "__NAMESPACE" | Where-Object { $_.Name -eq $_wmiNamespace }) {
    WRITE-HOST "The root\cimv2\$_wmiNamespace WMI namespace exists."
} Else {
    $wmi = [wmiclass]"root\cimv2:__Namespace"
    $newNamespace = $wmi.createInstance()
    $newNamespace.name = $_wmiNamespace
    $newNamespace.put()
}
# WMI Class
If (Get-WmiObject -List -Namespace "root\cimv2\$_wmiNamespace" | Where-Object {$_.Name -eq $_wmiClass})
{
    # The class exists, Let's clean it up.
    $GetExistingInstances = Get-WmiObject -Namespace "root\cimv2\$_wmiNamespace" -Class $_wmiClass
    If ($GetExistingInstances -ne $Null)
    {
        Remove-WMIObject -Namespace "root\cimv2\$_wmiNamespace" -Class $_wmiClass
    }
}
# Publish WMI Properties
$_subClass = New-Object System.Management.ManagementClass ("root\cimv2\$_wmiNamespace", [String]::Empty, $null);
$_subClass["__CLASS"] = $_wmiClass;
$_subClass.Qualifiers.Add("Static", $true)
$_subClass.Properties.Add("Name", [System.Management.CimType]::String, $false)
$_subClass.Properties["Name"].Qualifiers.Add("Key", $true) #A key qualifier must be defined to execute 'Put' command.
$_subClass.Properties.Add("Upload", [System.Management.CimType]::Real64, $false)
$_subClass.Properties.Add("Download", [System.Management.CimType]::Real64, $false)
$_subClass.Properties.Add("SpeedTestFail", [System.Management.CimType]::Real64, $false)
$_subClass.Put()
$keyvalue = "Bandwidth"
$Filter = 'Name= "' + $keyvalue + '"'
$Inst = Get-WmiObject -Class $_wmiClass -Filter $Filter -Namespace root\cimv2\$_wmiNamespace
$Inst | Remove-WMIObject
$WMIURL = 'root\cimv2\'+$_wmiNamespace+':'+$_wmiClass
$PushDataToWMI = ([wmiclass]$WMIURL).CreateInstance()
$PushDataToWMI.Name = $keyvalue
$PushDataToWMI.Upload = $_avgUpload
$PushDataToWMI.Download = $_avgDownload
$PushDataToWMI.SpeedTestFail = $_spFailureTrack
$PushDataToWMI.Put()
 
Hi, it is quite interesting and thanks for the code parameters.
I will try and then report to you.
Whatever be the speed of test sites or your ISP, is it not the network adapter which is mainly responsible for your internet speed? This speed is captured by wmi, and this speed is the actual download speed, I suppose. I may be wrong .
May I ask you why you have not used wmi.
I am already having a wmi script easy to use and it gets you the correct speed MBps speed.
The website like ookla servers may be far away from your place and it may not reflect the correct speed , as it always takes a example centre for speed purposes.
I will give the file here itself.
Just download autoit to your pc and then right click the au3 file and select run script
the script may be saved with extension au3. This is a thing to note
This is a script that I got from sevenforums
 

Attachments

Last edited:

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top