Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- REM For those wondering, this is a very complicated script. Modify it at your own risk.
- REM This pulls from PassMark's websites. All data related to your units should be there.
- REM If for any reason the script fails, which it will most likely close if it does, is
- REM because the script couldn't convert your CPU/GPU name to a valid HTML format.
- REM I have to remove the manufacturer name in order to make it a valid site.
- REM If possible, message me if it fails somehow. AMD hasn't been tested.
- REM At the time of finishing this, I saw that I can add Hard Drive
- REM and RAM. This may be included in an extended script.
- REM This took me around 8-12 hours to script and I've
- REM added comments to this script to explain it.
- REM This script creates 12 temporary files in which to
- REM decode and separate data. This cannot be avoided.
- REM http://imgur.com/28dfG9y
- REM Made by WesleyJB.
- REM These 2 'for' commands get the processing unit names
- for /F "tokens=* skip=1" %%n in ('WMIC path Win32_VideoController get Name ^| findstr "."') do set GPU_NAME=%%n
- echo %GPU_NAME% >gpu.adv
- for /F "tokens=* skip=1" %%n in ('WMIC cpu get Name ^| findstr "."') do set CPU_NAME=%%n
- echo %CPU_NAME% >cpu.adv
- REM Then we enable delayed expansion, which is required for the rest of the script to work right.
- SETLOCAL ENABLEDELAYEDEXPANSION
- REM With the first 2 commands we dumped the names to files. Now we have to remove certain things from the names.
- REM Since Intel is the only manufacturer of processors from what I know, we have to remove several things so we can get the data.
- REM It will return as "Intel(R) Series(R) Model CPU @ x.xx GHz."
- REM We need this as "Intel Series Model @ x.xx GHz"
- REM and "Series+Model+%40+x.xx+GHz."
- REM This section converts the CPU name into its HTML form.
- find "@" cpu.adv > cpus.adv
- for %%x in (cpus.adv) do (more +2 "%%x">tmp & move /y tmp "%%x")
- set /p string=<cpus.adv
- set string=%string:(R)=%
- set string=%string: =+%
- set string=%string:" "=%
- set string=%string:CPU=%
- set string=%string:+++=+%
- set string=%string:GHz+=GHz%
- set string=%string:++=+%
- set string=%string:++=+%
- set str1ng=%string%
- set replace=%%40
- set string=%string:@=!replace!%
- set CPU=%string%
- echo %CPU%>cpus.adv
- REM This section converts the CPU name into its written form.
- set str1ng=%str1ng:+= %
- set CPU=%str1ng%
- echo %CPU%>cpu.adv
- set /p CPU=<cpus.adv
- REM This next section codes a Visual Basic script that we need to use to access the information from the benchmark website.
- set urlben=//www.cpubenchmark.net/cpu.php?cpu=%CPU%
- echo %urlben%
- >"%temp%\geturl.vbs" echo url = "http:%urlben%"
- >>"%temp%\geturl.vbs" echo filename = "cpurating.adv"
- >>"%temp%\geturl.vbs" echo Set req = CreateObject("MSXML2.XMLHTTP.6.0")
- >>"%temp%\geturl.vbs" echo req.open "POST", url, False
- >>"%temp%\geturl.vbs" echo req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- >>"%temp%\geturl.vbs" echo req.send "field1=foo&field2=bar&..."
- >>"%temp%\geturl.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject")
- >>"%temp%\geturl.vbs" echo fso.OpenTextFile(filename, 2, True).WriteLine req.responseText
- REM Now we execute the VBScript and then delete it.
- cscript /nologo "%temp%\geturl.vbs"
- del "%temp%\geturl.vbs"
- REM Now we get to grabbing the information from our downloaded file.
- REM We get the rating,
- for %%i in (cpurating.adv) do (
- FINDSTR /C:"[rating]" %%i > cpubench.adv
- )
- REM the price,
- for %%i in (cpurating.adv) do (
- FINDSTR /C:"[price]" %%i > cpuprice.adv
- )
- REM and the rank.
- for %%i in (cpurating.adv) do (
- FINDSTR /C:"[rank]" %%i > cpurank.adv
- )
- REM Now that the info is separated, we need to remove unwanted HTML code.
- set N=0
- for /f "tokens=* delims= " %%c in (cpubench.adv) do (
- set /a N+=1
- if !N! lss 3 set S=!S!%%c
- ) > cpubench.adv echo.!S:~12!
- for /f "tokens=* skip=1 delims= " %%c in (cpubench.adv) do (
- echo.%%c
- ) > cpubench.adv
- set N=0
- for /f "tokens=* delims= " %%c in (cpuprice.adv) do (
- set /a N+=1
- if !N! lss 3 set S=!S!%%c
- ) > cpuprice.adv echo.!S:~27!
- for /f "tokens=* skip=1 delims= " %%c in (cpuprice.adv) do (
- echo.%%c
- ) > cpuprice.adv
- set N=0
- for /f "tokens=* delims= " %%c in (cpurank.adv) do (
- set /a N+=1
- if !N! lss 3 set S=!S!%%c
- ) > cpurank.adv echo.!S:~43!
- for /f "tokens=* skip=1 delims= " %%c in (cpurank.adv) do (
- echo.%%c
- ) > cpurank.adv
- REM Now we repeat the same process as before for the GPU.
- find "@" gpu.adv > gpus.adv
- for %%x in (gpus.adv) do (more +2 "%%x">tmp & move /y tmp "%%x")
- set /p string=<gpu.adv
- set string=%string:NVIDIA =%
- set string=%string:AMD =%
- set string=%string:ATI =%
- set string=%string:(R)=%
- set replace=%%2B
- set string=%string:+=!replace!%
- set string=%string: =+%
- set string=%string:+++=%
- set str1ng=%string%
- set str1ng=%str1ng:+= %
- set GPU=%string%
- echo %GPU%>gpus.adv
- set GPU=%str1ng%
- echo %GPU%>gpu.adv
- set /p GPU=<gpus.adv
- REM Grab the HTML page
- set urlben=//www.videocardbenchmark.net/gpu.php?gpu=%GPU%
- echo %urlben%
- >"%temp%\geturl.vbs" echo url = "http:%urlben%"
- >>"%temp%\geturl.vbs" echo filename = "gpurating.adv"
- >>"%temp%\geturl.vbs" echo Set req = CreateObject("MSXML2.XMLHTTP.6.0")
- >>"%temp%\geturl.vbs" echo req.open "POST", url, False
- >>"%temp%\geturl.vbs" echo req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- >>"%temp%\geturl.vbs" echo req.send "field1=foo&field2=bar&..."
- >>"%temp%\geturl.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject")
- >>"%temp%\geturl.vbs" echo fso.OpenTextFile(filename, 2, True).WriteLine req.responseText
- cscript /nologo "%temp%\geturl.vbs"
- del "%temp%\geturl.vbs"
- REM Grab the info
- REM This is different because the info isn't in a array like the CPU site.
- @echo on
- for %%i in (gpurating.adv) do (
- FINDSTR /C:"font-family: Arial, Helvetica, sans-serif;font-size: 35px; font-weight: bold; color: red;" %%i > gpubench.adv
- )
- for %%i in (gpurating.adv) do (
- FINDSTR /C:"Last Price Change" %%i > gpuprice.adv
- )
- for %%i in (gpurating.adv) do (
- FINDSTR /C:"Rank" %%i > gpurank.adv
- )
- REM Separate the info
- set N=0
- for /f "tokens=* delims= " %%a in (gpubench.adv) do (
- set /a N+=1
- if !N! lss 3 set S=!S!%%a
- ) > gpubench.adv echo.!S:~151!
- for /f "tokens=* skip=1 delims= " %%a in (gpubench.adv) do (
- echo.%%a
- ) > gpubench.adv
- for /f "tokens=*" %%a in (gpubench.adv) do (
- set xx=%%a
- set xx=!xx:~0,-15!
- echo.!xx! >gpubench.adv
- )
- REM Separate more info.
- set N=0
- for /f "tokens=* delims= " %%b in (gpuprice.adv) do (
- set /a N+=1
- if !N! lss 3 set S=!S!%%b
- ) > gpuprice.adv echo.!S:~239!
- for /f "tokens=* skip=1 delims= " %%b in (gpuprice.adv) do (
- echo.%%b
- ) > gpuprice.adv
- for /f "tokens=*" %%a in (gpuprice.adv) do (
- set xx=%%a
- set xx=!xx:~0,-19!
- echo.!xx! >gpuprice.adv
- )
- REM Since it's not in an array, we have to remove the code from behind the info.
- set N=0
- for /f "tokens=* delims= " %%c in (gpurank.adv) do (
- set /a N+=1
- if !N! lss 3 set S=!S!%%c
- )
- > gpurank.adv echo.!S:~436!
- for /f "tokens=* skip=1 delims= " %%c in (gpurank.adv) do (
- echo.%%c
- ) > gpurank.adv
- for /f "tokens=*" %%a in (gpurank.adv) do (
- set xx=%%a
- set xx=!xx:~0,-6!
- echo.!xx! >gpurank.adv
- )
- REM Now we conclude by putting all the information gathered into strings.
- set /p CPU=<cpu.adv
- set /p CPS=<cpubench.adv
- set /p CPP=<cpuprice.adv
- set /p CPR=<cpurank.adv
- set /p GPU=<gpu.adv
- set /p GPS=<gpubench.adv
- set /p GPP=<gpuprice.adv
- set /p GPR=<gpurank.adv
- @echo off
- rem cls
- REM Then we delete temporary data.
- del "cpu.adv"
- del "cpus.adv"
- del "cpurank.adv"
- del "cpuprice.adv"
- del "cpubench.adv"
- del "cpurating.adv"
- del "gpu.adv"
- del "gpus.adv"
- del "gpurank.adv"
- del "gpuprice.adv"
- del "gpubench.adv"
- del "gpurating.adv"
- REM And display the results.
- mode con cols=55 lines=29
- echo.
- echo Here are the PassMark CPU ^& GPU Benchmark ratings
- echo -------------------------------------------------------
- echo Central Processing Unit (CPU)
- echo.
- echo -------------------------------------------------------
- echo %CPU%:
- echo Rating: %CPS%
- echo Rank: %CPR%
- echo Price: $%CPP% USD
- echo.
- echo -------------------------------------------------------
- echo Graphics Processing Unit (GPU)
- echo.
- echo -------------------------------------------------------
- echo %GPU%:
- echo Rating: %GPS%
- echo Rank: %GPR%
- echo Price: %GPP%
- echo.
- echo -------------------------------------------------------
- echo Press any key to continue . . .
- echo.
- pause >nul
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement