You open it with notepad, set the .NET Framework, and then bundle it with your .NET X.X application.
NETCHK automatically checks .NET Framework with your OS version to make sure you are capable of getting .NET X.X
You might see NETCHK redirect to http://forums.everybodyedits.com/viewtopic.php?id=38084, but you can change that or just remove it altogether.
NETCHK is availible on github ( https://github.com/sirjosh3917/netchk )
If anybody would like to give feedback, test it on a different OS, or just generally help, please do ^-^
Code: Select all
::netchk.bat - A simple solution to checking .NET Framework versions for the user.
::
::Valid NETVersions:
::2.0
::3.0
::3.5
::4.0
::4.5
::4.5.1
::4.5.2
::4.6
::4.6.1
::4.6.2
::
::netchk.bat Automatically checks the version of windows to ensure that the specific
::version of .NET can be installed on the user's machine, and copies a download link
::to the user's clipboard.
::Set your bot details here.
@set "NETVersion=4.6.2"
::Leave the rest of the batch file be.
::Pre-requirements
@echo off
setlocal enabledelayedexpansion
title netchk.bat
color 0B
::Multiline-IF statement to check that the framework is O.K.
IF NOT "%NETVersion%" == "2.0" ^
IF NOT "%NETVersion%" == "3.0" ^
IF NOT "%NETVersion%" == "3.5" ^
IF NOT "%NETVersion%" == "4.0" ^
IF NOT "%NETVersion%" == "4.5" ^
IF NOT "%NETVersion%" == "4.5.1" ^
IF NOT "%NETVersion%" == "4.5.2" ^
IF NOT "%NETVersion%" == "4.6" ^
IF NOT "%NETVersion%" == "4.6.1" ^
IF NOT "%NETVersion%" == "4.6.2" ^
GOTO :NETCHK_OUTOFDATE
::Constants
set "NETBase=HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\"
set "2.0=v2.0.50727"
set "3.0=v3.0"
set "3.5=v3.5"
set "4.0=v4.0"
set "4.5=378389"
set "4.5.1[0]=378675"
set "4.5.1[1]=378758"
set "4.5.2=379893"
set "4.6[0]=393297"
set "4.6[1]=393295"
set "4.6.1[0]=394271"
set "4.6.1[1]=394254"
set "4.6.2[0]=394802"
set "4.6.2[1]=394806"
::Check Windows OS
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
SET "WINDOWS="
::Multiline-IF statement to check version type of windows, to make sure the OS is supported.
IF NOT "%VERSION%" == "5.0" ^
IF NOT "%VERSION%" == "5.1" ^
IF NOT "%VERSION%" == "5.2" ^
IF NOT "%VERSION%" == "6.0" ^
IF NOT "%VERSION%" == "6.1" ^
IF NOT "%VERSION%" == "6.2" ^
IF NOT "%VERSION%" == "6.3" ^
IF NOT "%VERSION%" == "10.0" ^
GOTO :WINDOWS_NOTSUPPORTED
IF "%VERSION%" == "5.0" SET "WINDOWS=Windows 2000"
IF "%VERSION%" == "5.1" SET "WINDOWS=Windows XP"
IF "%VERSION%" == "5.2" SET "WINDOWS=Windows XP"
IF "%VERSION%" == "6.0" SET "WINDOWS=Windows Vista"
IF "%VERSION%" == "6.1" SET "WINDOWS=Windows 7"
IF "%VERSION%" == "6.2" SET "WINDOWS=Windows 8"
IF "%VERSION%" == "6.3" SET "WINDOWS=Windows 8.1"
IF "%VERSION%" == "10.0" SET "WINDOWS=Windows 10"
::Windows 2000 ( SP4 ) can only support .NET 2.0
IF "%VERSION%" == "5.0" IF NOT "%NETVersion%" == "2.0" GOTO :NOTSUPPORTED
::Windows XP can only last up untill .NET 4
IF "%VERSION%" == "5.1" (
IF "%NETVersion%" == "2.0" GOTO :SUPPORTED
IF "%NETVersion%" == "3.0" GOTO :SUPPORTED
IF "%NETVersion%" == "3.5" GOTO :SUPPORTED
IF "%NETVersion%" == "4.0" GOTO :SUPPORTED
GOTO :NOTSUPPORTED
)
::Windows Vista ( SP2 ) can only last up untill .NET 4.6
IF "%VERSION%" == "6.0" (
IF NOT "%NETVersion%" == "4.6.1" IF NOT "%NETVersion%" == "4.6.2" GOTO :SUPPORTED
GOTO :NOTSUPPORTED
)
::Windows 7 ( SP1 ) and up can handle everything, so no need for checking.
:SUPPORTED
::Check version to quewry
SET "queryOld=true"
IF NOT "%NETVersion%" == "2.0" ^
IF NOT "%NETVersion%" == "3.0" ^
IF NOT "%NETVersion%" == "3.5" ^
IF NOT "%NETVersion%" == "4.0" ^
SET "queryOld=false"
GOTO :QUERY_OLD_%queryOld%
:QUERY_OLD_true
::Query the .NET Framework for 2.0, 3.0, 3.5.
REG QUERY "%NETBase%!%NETVersion%!" /v Version
IF %ERRORLEVEL% EQU 0 ( GOTO :NETRIGHT ) ELSE ( GOTO :NETWRONG )
echo.Easter Egg! How'd you get here?
:QUERY_OLD_false
::Query for .NET 4.0+
::Windows 7 requires "skip=2", Windows XP requires "skip=4". Not sure about other OSes.
SET "skip=2"
IF "%WINDOWS%" == "Windows XP" SET "skip=4"
::Querying
REG QUERY "%NETBase%v4\Full" /v Release>out.txt
SET "REGV=N"
FOR /F "usebackq skip=%skip% tokens=1-3" %%A IN (out.txt) DO (
set REGV=%%C
)
::Convert from 0x123456 to 123456
SET /A REGV=%REGV% + 0
del out.txt>nul
::Check .NET Framework requirements
IF "%NETVersion%" == "4.6.2" (
IF NOT "!REGV!" == "!4.6.2[0]!" ^
IF NOT "!REGV!" == "!4.6.2[1]!" GOTO :NETWRONG
)
IF "%NETVersion%" == "4.6.1" (
IF NOT "!REGV!" == "!4.6.1[0]!" ^
IF NOT "!REGV!" == "!4.6.1[1]!" ^
IF NOT "!REGV!" == "!4.6.2[0]!" ^
IF NOT "!REGV!" == "!4.6.2[1]!" GOTO :NETWRONG
)
IF "%NETVersion%" == "4.6" (
IF NOT "!REGV!" == "!4.6[0]!" ^
IF NOT "!REGV!" == "!4.6[1]!" ^
IF NOT "!REGV!" == "!4.6.1[0]!" ^
IF NOT "!REGV!" == "!4.6.1[1]!" ^
IF NOT "!REGV!" == "!4.6.2[0]!" ^
IF NOT "!REGV!" == "!4.6.2[1]!" GOTO :NETWRONG
)
IF "%NETVersion%" == "4.5.2" (
IF NOT "!REGV!" == "!4.5.2!" ^
IF NOT "!REGV!" == "!4.6[0]!" ^
IF NOT "!REGV!" == "!4.6[1]!" ^
IF NOT "!REGV!" == "!4.6.1[0]!" ^
IF NOT "!REGV!" == "!4.6.1[1]!" ^
IF NOT "!REGV!" == "!4.6.2[0]!" ^
IF NOT "!REGV!" == "!4.6.2[1]!" GOTO :NETWRONG
)
IF "%NETVersion%" == "4.5.1" (
IF NOT "!REGV!" == "!4.5.1[0]!" ^
IF NOT "!REGV!" == "!4.5.1[1]!" ^
IF NOT "!REGV!" == "!4.5.2!" ^
IF NOT "!REGV!" == "!4.6[0]!" ^
IF NOT "!REGV!" == "!4.6[1]!" ^
IF NOT "!REGV!" == "!4.6.1[0]!" ^
IF NOT "!REGV!" == "!4.6.1[1]!" ^
IF NOT "!REGV!" == "!4.6.2[0]!" ^
IF NOT "!REGV!" == "!4.6.2[1]!" GOTO :NETWRONG
)
::We were only checking if it was the wrong version of .NET
::If all checks are passed, we'll goto NETRIGHT automatically.
:NETRIGHT
::Congratulations! All the checks have passed, and it appears that
::the .NET version, and Windows, are O.K. There should be no errors!
echo.This bot appears to be able to be used by you!
echo.
echo.OS: %WINDOWS%
echo.OS Version: %VERSION%
echo..NET Framework Needed: %NETVersion%
echo.
echo.You may run the bot!
pause
exit /b 0
:NETWRONG
::The .NET Framework version appears to be not on the user's system.
::We'll notify them to get the correct version, and lead them to
::a forums topic to guide them towards what version of .NET to install.
echo.It appears you cannot use this bot, because you need a specific version of the .NET framework ( that you do not have )!
echo.
echo.The .NET Framework you need is %NETVersion%.
echo.
echo.Any information you need about .NET Framework downloading is availible here:
echo.http://forums.everybodyedits.com/viewtopic.php?id=38084
echo.
echo.Press any key to copy to clipboard
pause>nul
echo.http://forums.everybodyedits.com/viewtopic.php?id=38084|clip
echo.
echo.Link copied to clipboard.
pause
exit /b 0
:NETCHK_OUTOFDATE
::If NETCHK is out of date ( or an invalid NETFramework version was specified ), we'll spit an error.
echo.It appears NETCHK is out of date!
echo.The framework specified ( %NETVersion% ) is not a recognized framework.
echo.If you are the bot maker, try specify one of these versions:
echo.
echo.2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2
pause
exit /b 1
:WINDOWS_NOTSUPPORTED
::Make sure NETCHK is only doing what it can in it's bounds
::Meaning it can only operate on Windows:
::2000, XP, Vista, 7, 8, 8.1, and 10.
echo.It appears NETCHK is out of date!
echo.Your version of windows ( %VERSION% ) is not a recognized version of windows.
echo.Please contact the bot maker to update NETCHK.
echo.
pause
exit /b 1