REM If you're viewing this in a web browser or got to this text on a webpage, you may need to use your browser's back button, then right-click > Save/Download File As... REM and save it as a .bat file. @echo off cls SET err=0 echo ############################################################################### echo # Welcome to DSU's 802.1x Auto-Configuration Script! # echo # For help or updates to this script: help@dsu.edu or kyle.cronin@dsu.edu # echo # # echo # Disclaimer: This is for Windows-Only systems! # echo # Last updated: 24 Feburary 2017 # echo # # echo #Select the number that corresponds to the interface that you want setup # echo # Just enter the number, don't press return # echo ############################################################################### REM version history: REM 24 Feb: fixed bug with multiple network adapters and having spaces in their name REM fixed issue where users wouldn't get prompted to enter their credentials REM if the service isn't currently running, the service type will be set to auto now REM changed order so interfaces are scanned before anything else REM 23 Feb: initial creation goto check_permissions :check_permissions REM echo This script must be ran as an administrator. Detecting permissions... net session >nul 2>&1 if %errorLevel% == 0 ( REM echo Success: Administrative permissions confirmed. goto check_adapter ) else ( echo Failure: Current permissions inadequate. echo Re-run this script by right-clicking and selecting "Run As Administrator" echo or run under an Administrative Command Prompt SET err=1 goto failure ) REM endof check_permissions :check_adapter setLocal enableDelayedExpansion set intCounter = 0 set "choices=" for /f "skip=2 tokens=3*" %%A in ('netsh interface show interface') do ( set /a intCounter+=1 set int!intCounter!=%%B set choices=!choices!!intCounter! echo [!intCounter!] %%B ) choice /c !choices! /m "Select Interface: " /n set interface=!int%errorlevel%! goto check_service REM endof check_adapter :check_service echo Checking Windows services... net start | find "Wired AutoConfig" > nul 2>&1 if not %errorlevel% == 0 goto start_service REM echo The Wired AutoConfig service is already running goto write_file REM endof check_service :start_service echo Changing service configuration... sc config dot3svc start=auto > nul 2>&1 net start "Wired AutoConfig" REM > nul 2>&1 REM endof start_service :write_file echo Generating configuration file... @echo ^ > config.xml @echo ^ >> config.xml @echo ^ >> config.xml @echo ^ >> config.xml @echo ^false^ >> config.xml @echo ^true^ >> config.xml @echo ^ >> config.xml @echo ^true^ >> config.xml @echo ^user^ >> config.xml @echo ^^^^25^^0^^0^^0^^^^^25^^^^false^^^^^true^^false^^^26^^^false^^^^false^^false^^^false^^false^^^^^^^ >> config.xml @echo ^ >> config.xml @echo ^ >> config.xml @echo ^ >> config.xml @echo ^ >> config.xml goto set_parameters REM endof write_file :set_parameters REM netsh lan set profileparameter oneXEnabled=yes interface=%interface% REM netsh lan set profileparameter authMode=userOnly interface=%interface% echo Applying configuration to %interface% netsh lan add profile filename=config.xml interface=%interface% >nul 2>&1 netsh interface ip set address name=%interface% source=dhcp >nul 2>&1 netsh interface ip set dns name=%interface% source=dhcp >nul 2>&1 del config.xml echo Done!!! echo If no errors have appeared, the script should have completed successfully! echo You may need to unplug/plug in your wired network adapter to be prompted for your username and password echo Make sure to enter your DSU username with a \, like: dsu\totesgoats pause exit if %errorLevel% == 0 ( REM success ) else ( echo Could not apply the profile settings to your adapter goto failure REM endof set_parameters :failure echo The script was unable to complete successfully. Look for errors above and try again. pause exit