- Messages
- 1,264
- Reaction score
- 2
- Points
- 28
I need to run this file but I'm not completely sure if it contains any malicious commands or not. Also, I would like to know if the information that this script will get from my computer will have privacy issue or threat. What's with the Bios serial number? Are there any threat in letting people know my bios serial number? What's with the web.vbs and email.vbs? Thanks for any help.
:: System Diagnostics v5.0
:: By: xxxxxxxxxx
:ate: November 2015
@echo off
setlocal enabledelayedexpansion
::==================================== Start of Main Routine
setlocal enabledelayedexpansion
title System Diagnostics v5.0
::=================================================== Set Color and Window Size
color 0E
mode con: cols=110 lines=45
::=================================================== Checking OS Version and connection mode
sCheck
ver | findstr /i "6\.1\." > nul
IF %errorlevel% EQU 0 goto ver_Win7
ver | findstr /i "6\.3\." > nul
IF %errorlevel% EQU 0 goto ver_Win8
ver | findstr /i "10\.0\." > nul
IF %errorlevel% EQU 0 goto ver_Win10
:ver_Win7
:: Checking Network Adapter
netsh interface show interface name="Wireless Network Connection" | findstr "Connected" > nul && goto WiFiOn
netsh interface show interface name="Local Area Connection" | findstr "Connected" > nul && goto procTest
:ver_Win8
::Checking Network Adapter
netsh interface show interface name="Wi-Fi" | findstr "Connected" > nul && goto WiFiOn
netsh interface show interface name="Ethernet" | findstr "Connected" > nul && goto procTest
:ver_Win10
::Checking Network Adapter
netsh interface show interface name="Wi-Fi" | findstr "Connected" > nul && goto WiFiOn
netsh interface show interface name="Ethernet" | findstr "Connected" > nul && goto procTest
:WiFiOn
echo Your Wireless Connection is active.
echo Please disconnect your Wireless Connection first.
echo Make sure that you are only connected to your Home Network using a LAN Cable.
echo Once connected, press on any key to continue
Pause>nul
goto Proctest
::====================================================== checking running processes
rocTest
cls
tasklist /nh /fi "imagename eq Launch.exe" | findstr /i /c:"Launch.exe" >nul && goto runningProc || goto nextProc
:nextProc
tasklist /nh /fi "imagename eq imclient.exe" | findstr /i /c:"imclient.exe" >nul && goto runningProc || goto nextProc2
:nextProc2
tasklist /nh /fi "imagename eq QQ.exe" | findstr /i /c:"qq.exe" >nul && goto runningProc || goto startTest
:runningProc
echo Either AC or QQ is running. Running System Test while these applications are active will
echo affect the result of the test.
echo.
set Choice=
set /p Choice=If you don't have a class you can terminate AC / QQ. Do you want the script to terminate these applications (Yes or No)
If "%Choice%"=="Y" goto terminate
If "%Choice%"=="y" goto terminate
If "%Choice%"=="Yes" goto terminate
If "%Choice%"=="yes" goto terminate
If "%Choice%"=="N" goto ifNo
If "%Choice%"=="n" goto ifNo
If "%Choice%"=="No" goto ifNo
If "%Choice%"=="no" goto ifNo
:ifNo
echo.
echo Run the System Test after your class.
Pause>nul
goto end
:terminate
tasklist /nh /fi "imagename eq Launch.exe">nul | findstr /i /c:"Launch.exe">nul
taskkill -IM Launch.exe -F 2>nul || goto terminate2
:terminate2
tasklist /nh /fi "imagename eq imclient.exe">nul | findstr /i /c:"imclient.exe">nul
taskkill -IM imclient.exe -F 2>nul || goto terminate3
:terminate3
tasklist /nh /fi "imagename eq QQ.exe">nul | findstr /i /c:"qq.exe">nul
taskkill -IM qq.exe -F 2>nul || goto startTest
:startTest
mkdir %userprofile%\Desktop\xxx_SysDiag 2>nul
cd %userprofile%\Desktop\xxx_SysDiag
set cDir=%userprofile%\Desktop\xxx_SysDiag
set startTime=%TIME%
set Status=OK
echo System Diagnostics Report > TestResult.txt
echo. >> TestResult.txt
echo ================================================
echo SYSTEM DIAGNOSTICS v5.0
echo ================================================
echo.
set /p Name=Please enter your Name:
set /p Phone=Please enter your Contact (Home/Mobile Phone) number:
set /p Email=Please enter your Email Address:
echo Teacher Name: %Name% Phone number %Phone% >> TestResult.txt
echo Email Address: %Email% >> TestResult.txt
echo ________________________________________________>> TestResult.txt
echo Date: %Date% Time: %Time%>> TestResult.txt
echo ________________________________________________>> TestResult.txt
echo.
echo ================================================
echo RUNNING SYSTEM DIAGNOSTICS
echo ================================================
set procName=torrent
echo.
set /p var=Cleaning Processes.....<nul
for /f "tokens=1 delims=," %%a in ('tasklist /fo csv ^| findstr /I /C:"%procName%"') do callillProc %%a
illProc
taskkill /f /im "%*">nul 2>&1
echo OK
::Checking LAN IP Address
echo.
set /p var=Checking LAN IP Address.....<nul
For /F "tokens=14 delims= " %%a IN ('ipconfig^| findstr /I /C:"IPv4"') Do echo LAN IP Address: %%a >> TestResult.txt
ping 1.1.1.1 -n 1 -w 1000 > nul
echo OK
echo.
echo.>>TestResult.txt
echo WAN Information >> TestResult.txt
echo.>>TestResult.txt
::=============================Checking WAN IP Address
cd %userprofile%\Desktop\xxx_SysDiag
set /p var=Checking WAN Information.....<nul
echo Option Explicit > web.vbs
echo Dim objXMLhttp, objFSO, objTS >> web.vbs
echo Const FSO_OVERWRITE = True >> web.vbs
echo Set objXMLhttp = CreateObject("MSXML2.XMLhttp") >> web.vbs
echo With objXMLhttp >> web.vbs
echo .open "GET", "http://ipinfo.io/json", False >> web.vbs
echo On Error Resume Next >> web.vbs
echo .send >> web.vbs
echo Set objFSO = CreateObject("Scripting.FileSystemObject") >> web.vbs
echo Set objTS = objFSO.CreateTextFile("ISP.txt", FSO_OVERWRITE) >> web.vbs
echo objTS.Write Replace(.responseText, vbLf, vbNewLine) >> web.vbs
echo objTS.Close >> web.vbs
echo Set objTS = Nothing >> web.vbs
echo Set objFSO = Nothing >> web.vbs
echo End With >> web.vbs
echo Set objXMLhttp = Nothing >> web.vbs
"web.vbs"
type ISP.TXT >> TestResult.txt
del /q web.vbs
del /q ISP.txt
echo OK
echo. >> TestResult.txt
::Checking OS
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"Total Physical Memory" /C:"Available Physical Memory" /C:"System Manufacturer" /C:"System Model">> TestResult.txt
echo. >> TestResult.txt
::Checking Processors
echo.
set /p var=Checking System Information.....<nul
echo Computer Name: >> TestResult.txt
echo %ComputerName% >> TestResult.txt
echo Processor: >> TestResult.txt
wmic cpu get Name | findstr /C:"@" >> TestResult.txt
echo Number of Cores: >> TestResult.txt
wmic cpu get NumberofCores | findstr "[0-9]" >> TestResult.txt
echo BIOS Serial Number: >> TestResult.txt
wmic bios get serialnumber | findstr "[0-9]" >> TestResult.txt
ping 1.1.1.1 -n 1 -w 1000 > nul
echo OK
echo.
::Running PING
setlocal enableextensions disabledelayedexpansion
echo _________________________________ >> TestResult.txt
for /f %%a in ('copy "%~f0" nul /z') do set "CR=%%a"
set "lockFile=%temp%\%~nx0.%random%%random%.lock"
set "count=0"
set "loop= for /l %%a in (0) do "
set "wait= ping -n 1 1.1.1.1"
set "countDown= set /A "count=count+1""
set "progress= set /p"=Running Compatibility Test 1...percent %% !count:~0,3!!CR!">con"
set "check= type nul >>"%lockFile%" "
set "atEnd= del /q "%lockFile%" & echo Running Compatibility Test 1.................OK >con & exit"
(
9>"%lockFile%" ping -n 300 175.100.204.130 | findstr /I /C:"Lost" /C:"Average" > output.txt
) | <nul >nul 2>&1 (
cmd /v /q /c "%loop% ( %wait% & %countDown% & (( %check% )&&( %atEnd% )||( %progress% )))"
)
setlocal enabledelayedexpansion
For /F "tokens=3 delims=," %%a in (output.txt) DO echo %%a >> TestResult.txt
echo.
echo _________________________________ >>TestResult.txt
del /q "output.txt"
:: Running PING MNL Node
setlocal enableextensions disabledelayedexpansion
echo _________________________________ >> TestResult.txt
for /f %%a in ('copy "%~f0" nul /z') do set "CR=%%a"
set "lockFile=%temp%\%~nx0.%random%%random%.lock"
set "count=0"
set "loop= for /l %%a in (0) do "
set "wait= ping -n 1 1.1.1.1"
set "countDown= set /A "count=count+1""
set "progress= set /p"=Running Compatibility Test 2...percent %% !count:~0,3!!CR!">con"
set "check= type nul >>"%lockFile%" "
set "atEnd= del /q "%lockFile%" & echo Running Compatibility Test 1.................OK >con & exit"
(
9>"%lockFile%" ping -n 300 121.58.225.202 | findstr /I /C:"Lost" /C:"Average" > output.txt
) | <nul >nul 2>&1 (
cmd /v /q /c "%loop% ( %wait% & %countDown% & (( %check% )&&( %atEnd% )||( %progress% )))"
)
setlocal enabledelayedexpansion
For /F "tokens=3 delims=," %%a in (output.txt) DO echo %%a >> TestResult.txt
echo.
echo _________________________________ >>TestResult.txt
del /q "output.txt"
::Running tracert
setlocal enableextensions disabledelayedexpansion
::set "logFile=output.txt"
echo. >> TestResult.txt
for /f %%a in ('copy "%~f0" nul /z') do set "CR=%%a"
set "lockFile=%temp%\%~nx0.%random%%random%.lock"
set "count=0"
set "loop= for /l %%a in (0) do "
set "wait= ping -n 1 1.1.1.1"
set "countDown= set /A "count=count+1""
set "progress= set /p"=Running Compatibility Test 3... percent %% !count:~0,3!!CR!">con"
set "check= type nul >>"%lockFile%" "
set "atEnd= del /q "%lockFile%" & echo Running Compatibility Test 1.................OK >con & exit"
(
9>"%lockFile%" tracert 175.100.204.130 | findstr /I /C:"ms" >> TestResult.txt
) | <nul >nul 2>&1 (
cmd /v /q /c "%loop% ( %wait% & %countDown% & (( %check% )&&( %atEnd% )||( %progress% )))"
)
echo _________________________________ >> TestResult.txt
set endTime=%TIME%
::running Speedtest
setlocal enabledelayedexpansion
echo.
set /p var=Opening SpeedTest.net website.....<nul
ping -n 1 1.1.1.1 -w 1000 >nul
start http://www.speedtest.net
ping -n 1 1.1.1.1 -w 1000 >nul
echo OK
echo.
echo For SpeedTest, make sure to set the Test Server as "Hong Kong" before you click on "Begin Test"
echo Once Speed test is done, click on "Share This Result" button
echo Click on Copy button to copy the result link and paste it below (right-click and select Copy):
echo.
echo Note: If you are having a problem with running the speedtest, type the word "skip" and press on Enter.
echo.
:enterSpeedTest
set /P SpeedTest= SpeedTest_Link:
echo %speedtest% | Findstr /I /C:"skip" >nul && goto testMy
echo %speedtest% | Findstr /R /C:"http://www.speedtest.net/my-result/" >nul
IF errorlevel 1 (goto nullSpeedTest)
echo Speedtest: %SpeedTest% >> TestResult.txt
echo.
:testMy
set /p var=Opening TestMy.net website.....<nul
ping -n 1 1.1.1.1 -w 1000 >nul
start http://cn.testmy.net/SmarTest/combinedAuto
ping -n 1 1.1.1.1 -w 1000 >nul
echo OK
echo.
echo Once the test is done, click on "Share This Result"
echo Copy the Result URL and paste it below (right-click and select Copy):\
echo.
echo Note: If you are having a problem with running the TestMy, type the word "skip" and press on Enter.
echo.
:enterTestMy
set /P TestMy= TestMy_Link:
echo %TestMy% | findstr /I /C:"skip" >nul && goto runtime
echo %TestMy% | findstr /R /C:"http://testmy.net/" >nul
IF errorlevel 1 (goto nullTestMy)
echo TestMy: %TestMy% >> TestResult.txt
echo.
:runtime
::=========================================Calculate total runtime
for /F "tokens=1-4 delims=:.," %%a in ("%STARTTIME%") do (
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
for /F "tokens=1-4 delims=:.," %%a in ("%ENDTIME%") do (
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
set /A elapsed=end-start
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
if %hh% lss 10 set hh=0%hh%
if %mm% lss 10 set mm=0%mm%
if %ss% lss 10 set ss=0%ss%
if %cc% lss 10 set cc=0%cc%
set DURATION=%hh%:%mm%:%ss%
echo. >> TestResult.txt
echo Total Runtime Duration : %DURATION% >>TestResult.txt
::=====email result file
cd %userprofile%\Desktop\xxx_SysDiag
echo Set emailObj = CreateObject("CDO.Message") > email.vbs
echo emailObj.Subject = "Test Result %Name% %Hostname%" >> email.vbs
echo emailObj.From = "[email protected]" >> email.vbs
echo emailObj.To = "[email protected]" >> email.vbs
echo emailObj.TextBody = "%Name% %Hostname% %date% %time%" >> email.vbs
echo emailObj.AddAttachment "%cDir%\TestResult.txt" >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]" >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxx_xxx" >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.gmail.com" >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl")=1 >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=465 >> email.vbs
echo emailObj.Configuration.Fields.Update >> email.vbs
echo emailObj.Send >> email.vbs
echo If err.number = 0 Then MsgBox "Done with sending the result file to [email protected]. Please inform your facilitator that the test is completed." >> email.vbs
"email.vbs"
goto End
:nullspeedtest
echo Invalid link or blank. Please enter the Speed Test Result Link to continue....
goto enterSpeedTest
:nullTestMy
echo Invalid link or blank. Please enter the TestMy Result link to continue.....
goto enterTestMy
:end
cd %userprofile%\Desktop\xxx_SysDiag
del /q email.vbs
:: System Diagnostics v5.0
:: By: xxxxxxxxxx
:ate: November 2015
@echo off
setlocal enabledelayedexpansion
::==================================== Start of Main Routine
setlocal enabledelayedexpansion
title System Diagnostics v5.0
::=================================================== Set Color and Window Size
color 0E
mode con: cols=110 lines=45
::=================================================== Checking OS Version and connection mode
sCheck
ver | findstr /i "6\.1\." > nul
IF %errorlevel% EQU 0 goto ver_Win7
ver | findstr /i "6\.3\." > nul
IF %errorlevel% EQU 0 goto ver_Win8
ver | findstr /i "10\.0\." > nul
IF %errorlevel% EQU 0 goto ver_Win10
:ver_Win7
:: Checking Network Adapter
netsh interface show interface name="Wireless Network Connection" | findstr "Connected" > nul && goto WiFiOn
netsh interface show interface name="Local Area Connection" | findstr "Connected" > nul && goto procTest
:ver_Win8
::Checking Network Adapter
netsh interface show interface name="Wi-Fi" | findstr "Connected" > nul && goto WiFiOn
netsh interface show interface name="Ethernet" | findstr "Connected" > nul && goto procTest
:ver_Win10
::Checking Network Adapter
netsh interface show interface name="Wi-Fi" | findstr "Connected" > nul && goto WiFiOn
netsh interface show interface name="Ethernet" | findstr "Connected" > nul && goto procTest
:WiFiOn
echo Your Wireless Connection is active.
echo Please disconnect your Wireless Connection first.
echo Make sure that you are only connected to your Home Network using a LAN Cable.
echo Once connected, press on any key to continue
Pause>nul
goto Proctest
::====================================================== checking running processes
rocTest
cls
tasklist /nh /fi "imagename eq Launch.exe" | findstr /i /c:"Launch.exe" >nul && goto runningProc || goto nextProc
:nextProc
tasklist /nh /fi "imagename eq imclient.exe" | findstr /i /c:"imclient.exe" >nul && goto runningProc || goto nextProc2
:nextProc2
tasklist /nh /fi "imagename eq QQ.exe" | findstr /i /c:"qq.exe" >nul && goto runningProc || goto startTest
:runningProc
echo Either AC or QQ is running. Running System Test while these applications are active will
echo affect the result of the test.
echo.
set Choice=
set /p Choice=If you don't have a class you can terminate AC / QQ. Do you want the script to terminate these applications (Yes or No)
If "%Choice%"=="Y" goto terminate
If "%Choice%"=="y" goto terminate
If "%Choice%"=="Yes" goto terminate
If "%Choice%"=="yes" goto terminate
If "%Choice%"=="N" goto ifNo
If "%Choice%"=="n" goto ifNo
If "%Choice%"=="No" goto ifNo
If "%Choice%"=="no" goto ifNo
:ifNo
echo.
echo Run the System Test after your class.
Pause>nul
goto end
:terminate
tasklist /nh /fi "imagename eq Launch.exe">nul | findstr /i /c:"Launch.exe">nul
taskkill -IM Launch.exe -F 2>nul || goto terminate2
:terminate2
tasklist /nh /fi "imagename eq imclient.exe">nul | findstr /i /c:"imclient.exe">nul
taskkill -IM imclient.exe -F 2>nul || goto terminate3
:terminate3
tasklist /nh /fi "imagename eq QQ.exe">nul | findstr /i /c:"qq.exe">nul
taskkill -IM qq.exe -F 2>nul || goto startTest
:startTest
mkdir %userprofile%\Desktop\xxx_SysDiag 2>nul
cd %userprofile%\Desktop\xxx_SysDiag
set cDir=%userprofile%\Desktop\xxx_SysDiag
set startTime=%TIME%
set Status=OK
echo System Diagnostics Report > TestResult.txt
echo. >> TestResult.txt
echo ================================================
echo SYSTEM DIAGNOSTICS v5.0
echo ================================================
echo.
set /p Name=Please enter your Name:
set /p Phone=Please enter your Contact (Home/Mobile Phone) number:
set /p Email=Please enter your Email Address:
echo Teacher Name: %Name% Phone number %Phone% >> TestResult.txt
echo Email Address: %Email% >> TestResult.txt
echo ________________________________________________>> TestResult.txt
echo Date: %Date% Time: %Time%>> TestResult.txt
echo ________________________________________________>> TestResult.txt
echo.
echo ================================================
echo RUNNING SYSTEM DIAGNOSTICS
echo ================================================
set procName=torrent
echo.
set /p var=Cleaning Processes.....<nul
for /f "tokens=1 delims=," %%a in ('tasklist /fo csv ^| findstr /I /C:"%procName%"') do callillProc %%a
illProc
taskkill /f /im "%*">nul 2>&1
echo OK
::Checking LAN IP Address
echo.
set /p var=Checking LAN IP Address.....<nul
For /F "tokens=14 delims= " %%a IN ('ipconfig^| findstr /I /C:"IPv4"') Do echo LAN IP Address: %%a >> TestResult.txt
ping 1.1.1.1 -n 1 -w 1000 > nul
echo OK
echo.
echo.>>TestResult.txt
echo WAN Information >> TestResult.txt
echo.>>TestResult.txt
::=============================Checking WAN IP Address
cd %userprofile%\Desktop\xxx_SysDiag
set /p var=Checking WAN Information.....<nul
echo Option Explicit > web.vbs
echo Dim objXMLhttp, objFSO, objTS >> web.vbs
echo Const FSO_OVERWRITE = True >> web.vbs
echo Set objXMLhttp = CreateObject("MSXML2.XMLhttp") >> web.vbs
echo With objXMLhttp >> web.vbs
echo .open "GET", "http://ipinfo.io/json", False >> web.vbs
echo On Error Resume Next >> web.vbs
echo .send >> web.vbs
echo Set objFSO = CreateObject("Scripting.FileSystemObject") >> web.vbs
echo Set objTS = objFSO.CreateTextFile("ISP.txt", FSO_OVERWRITE) >> web.vbs
echo objTS.Write Replace(.responseText, vbLf, vbNewLine) >> web.vbs
echo objTS.Close >> web.vbs
echo Set objTS = Nothing >> web.vbs
echo Set objFSO = Nothing >> web.vbs
echo End With >> web.vbs
echo Set objXMLhttp = Nothing >> web.vbs
"web.vbs"
type ISP.TXT >> TestResult.txt
del /q web.vbs
del /q ISP.txt
echo OK
echo. >> TestResult.txt
::Checking OS
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"Total Physical Memory" /C:"Available Physical Memory" /C:"System Manufacturer" /C:"System Model">> TestResult.txt
echo. >> TestResult.txt
::Checking Processors
echo.
set /p var=Checking System Information.....<nul
echo Computer Name: >> TestResult.txt
echo %ComputerName% >> TestResult.txt
echo Processor: >> TestResult.txt
wmic cpu get Name | findstr /C:"@" >> TestResult.txt
echo Number of Cores: >> TestResult.txt
wmic cpu get NumberofCores | findstr "[0-9]" >> TestResult.txt
echo BIOS Serial Number: >> TestResult.txt
wmic bios get serialnumber | findstr "[0-9]" >> TestResult.txt
ping 1.1.1.1 -n 1 -w 1000 > nul
echo OK
echo.
::Running PING
setlocal enableextensions disabledelayedexpansion
echo _________________________________ >> TestResult.txt
for /f %%a in ('copy "%~f0" nul /z') do set "CR=%%a"
set "lockFile=%temp%\%~nx0.%random%%random%.lock"
set "count=0"
set "loop= for /l %%a in (0) do "
set "wait= ping -n 1 1.1.1.1"
set "countDown= set /A "count=count+1""
set "progress= set /p"=Running Compatibility Test 1...percent %% !count:~0,3!!CR!">con"
set "check= type nul >>"%lockFile%" "
set "atEnd= del /q "%lockFile%" & echo Running Compatibility Test 1.................OK >con & exit"
(
9>"%lockFile%" ping -n 300 175.100.204.130 | findstr /I /C:"Lost" /C:"Average" > output.txt
) | <nul >nul 2>&1 (
cmd /v /q /c "%loop% ( %wait% & %countDown% & (( %check% )&&( %atEnd% )||( %progress% )))"
)
setlocal enabledelayedexpansion
For /F "tokens=3 delims=," %%a in (output.txt) DO echo %%a >> TestResult.txt
echo.
echo _________________________________ >>TestResult.txt
del /q "output.txt"
:: Running PING MNL Node
setlocal enableextensions disabledelayedexpansion
echo _________________________________ >> TestResult.txt
for /f %%a in ('copy "%~f0" nul /z') do set "CR=%%a"
set "lockFile=%temp%\%~nx0.%random%%random%.lock"
set "count=0"
set "loop= for /l %%a in (0) do "
set "wait= ping -n 1 1.1.1.1"
set "countDown= set /A "count=count+1""
set "progress= set /p"=Running Compatibility Test 2...percent %% !count:~0,3!!CR!">con"
set "check= type nul >>"%lockFile%" "
set "atEnd= del /q "%lockFile%" & echo Running Compatibility Test 1.................OK >con & exit"
(
9>"%lockFile%" ping -n 300 121.58.225.202 | findstr /I /C:"Lost" /C:"Average" > output.txt
) | <nul >nul 2>&1 (
cmd /v /q /c "%loop% ( %wait% & %countDown% & (( %check% )&&( %atEnd% )||( %progress% )))"
)
setlocal enabledelayedexpansion
For /F "tokens=3 delims=," %%a in (output.txt) DO echo %%a >> TestResult.txt
echo.
echo _________________________________ >>TestResult.txt
del /q "output.txt"
::Running tracert
setlocal enableextensions disabledelayedexpansion
::set "logFile=output.txt"
echo. >> TestResult.txt
for /f %%a in ('copy "%~f0" nul /z') do set "CR=%%a"
set "lockFile=%temp%\%~nx0.%random%%random%.lock"
set "count=0"
set "loop= for /l %%a in (0) do "
set "wait= ping -n 1 1.1.1.1"
set "countDown= set /A "count=count+1""
set "progress= set /p"=Running Compatibility Test 3... percent %% !count:~0,3!!CR!">con"
set "check= type nul >>"%lockFile%" "
set "atEnd= del /q "%lockFile%" & echo Running Compatibility Test 1.................OK >con & exit"
(
9>"%lockFile%" tracert 175.100.204.130 | findstr /I /C:"ms" >> TestResult.txt
) | <nul >nul 2>&1 (
cmd /v /q /c "%loop% ( %wait% & %countDown% & (( %check% )&&( %atEnd% )||( %progress% )))"
)
echo _________________________________ >> TestResult.txt
set endTime=%TIME%
::running Speedtest
setlocal enabledelayedexpansion
echo.
set /p var=Opening SpeedTest.net website.....<nul
ping -n 1 1.1.1.1 -w 1000 >nul
start http://www.speedtest.net
ping -n 1 1.1.1.1 -w 1000 >nul
echo OK
echo.
echo For SpeedTest, make sure to set the Test Server as "Hong Kong" before you click on "Begin Test"
echo Once Speed test is done, click on "Share This Result" button
echo Click on Copy button to copy the result link and paste it below (right-click and select Copy):
echo.
echo Note: If you are having a problem with running the speedtest, type the word "skip" and press on Enter.
echo.
:enterSpeedTest
set /P SpeedTest= SpeedTest_Link:
echo %speedtest% | Findstr /I /C:"skip" >nul && goto testMy
echo %speedtest% | Findstr /R /C:"http://www.speedtest.net/my-result/" >nul
IF errorlevel 1 (goto nullSpeedTest)
echo Speedtest: %SpeedTest% >> TestResult.txt
echo.
:testMy
set /p var=Opening TestMy.net website.....<nul
ping -n 1 1.1.1.1 -w 1000 >nul
start http://cn.testmy.net/SmarTest/combinedAuto
ping -n 1 1.1.1.1 -w 1000 >nul
echo OK
echo.
echo Once the test is done, click on "Share This Result"
echo Copy the Result URL and paste it below (right-click and select Copy):\
echo.
echo Note: If you are having a problem with running the TestMy, type the word "skip" and press on Enter.
echo.
:enterTestMy
set /P TestMy= TestMy_Link:
echo %TestMy% | findstr /I /C:"skip" >nul && goto runtime
echo %TestMy% | findstr /R /C:"http://testmy.net/" >nul
IF errorlevel 1 (goto nullTestMy)
echo TestMy: %TestMy% >> TestResult.txt
echo.
:runtime
::=========================================Calculate total runtime
for /F "tokens=1-4 delims=:.," %%a in ("%STARTTIME%") do (
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
for /F "tokens=1-4 delims=:.," %%a in ("%ENDTIME%") do (
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
set /A elapsed=end-start
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
if %hh% lss 10 set hh=0%hh%
if %mm% lss 10 set mm=0%mm%
if %ss% lss 10 set ss=0%ss%
if %cc% lss 10 set cc=0%cc%
set DURATION=%hh%:%mm%:%ss%
echo. >> TestResult.txt
echo Total Runtime Duration : %DURATION% >>TestResult.txt
::=====email result file
cd %userprofile%\Desktop\xxx_SysDiag
echo Set emailObj = CreateObject("CDO.Message") > email.vbs
echo emailObj.Subject = "Test Result %Name% %Hostname%" >> email.vbs
echo emailObj.From = "[email protected]" >> email.vbs
echo emailObj.To = "[email protected]" >> email.vbs
echo emailObj.TextBody = "%Name% %Hostname% %date% %time%" >> email.vbs
echo emailObj.AddAttachment "%cDir%\TestResult.txt" >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]" >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxx_xxx" >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.gmail.com" >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl")=1 >> email.vbs
echo emailObj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=465 >> email.vbs
echo emailObj.Configuration.Fields.Update >> email.vbs
echo emailObj.Send >> email.vbs
echo If err.number = 0 Then MsgBox "Done with sending the result file to [email protected]. Please inform your facilitator that the test is completed." >> email.vbs
"email.vbs"
goto End
:nullspeedtest
echo Invalid link or blank. Please enter the Speed Test Result Link to continue....
goto enterSpeedTest
:nullTestMy
echo Invalid link or blank. Please enter the TestMy Result link to continue.....
goto enterTestMy
:end
cd %userprofile%\Desktop\xxx_SysDiag
del /q email.vbs