@echo off
setlocal enabledelayedexpansion

:: Ruta donde se guardará el archivo XML temporal
set "xmlPath=%TEMP%\eduxuntagal.xml"

:: Crear el archivo XML línea por línea
> "%xmlPath%" (
echo ^<?xml version="1.0"?^>
echo ^<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"^>
echo     ^<name^>edu.xunta.gal^</name^>
echo     ^<SSIDConfig^>
echo         ^<SSID^>
echo             ^<hex^>6564752E78756E74612E67616C^</hex^>
echo             ^<name^>edu.xunta.gal^</name^>
echo         ^</SSID^>
echo         ^<nonBroadcast^>true^</nonBroadcast^>
echo     ^</SSIDConfig^>
echo     ^<connectionType^>ESS^</connectionType^>
echo     ^<connectionMode^>manual^</connectionMode^>
echo     ^<autoSwitch^>false^</autoSwitch^>
echo     ^<MSM^>
echo         ^<security^>
echo             ^<authEncryption^>
echo                 ^<authentication^>WPA2^</authentication^>
echo                 ^<encryption^>AES^</encryption^>
echo                 ^<useOneX^>true^</useOneX^>
echo             ^</authEncryption^>
echo             ^<OneX xmlns="http://www.microsoft.com/networking/OneX/v1"^>
echo                 ^<cacheUserData^>false^</cacheUserData^>
echo                 ^<authMode^>user^</authMode^>
echo                 ^<EAPConfig^>
echo                     ^<EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"^>
echo                         ^<EapMethod^>
echo                             ^<Type xmlns="http://www.microsoft.com/provisioning/EapCommon"^>21^</Type^>
echo                             ^<VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon"^>0^</VendorId^>
echo                             ^<VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon"^>0^</VendorType^>
echo                             ^<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon"^>311^</AuthorId^>
echo                         ^</EapMethod^>
echo                         ^<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"^>
echo                             ^<EapTtls xmlns="http://www.microsoft.com/provisioning/EapTtlsConnectionPropertiesV1"^>
echo                                 ^<ServerValidation^>
echo                                     ^<ServerNames^>edu.xunta.gal^</ServerNames^>
echo                                     ^<TrustedRootCAHash^>66 f1 77 c3 3e 6c a9 a5 24 af 11 d7 6f 52 37 f0 ac db bf 24^</TrustedRootCAHash^>
echo                                     ^<DisablePrompt^>false^</DisablePrompt^>
echo                                 ^</ServerValidation^>
echo                                 ^<Phase2Authentication^>
echo                                     ^<PAPAuthentication /^>
echo                                 ^</Phase2Authentication^>
echo                                 ^<Phase1Identity^>
echo                                     ^<IdentityPrivacy^>false^</IdentityPrivacy^>
echo                                 ^</Phase1Identity^>
echo                             ^</EapTtls^>
echo                         ^</Config^>
echo                     ^</EapHostConfig^>
echo                 ^</EAPConfig^>
echo             ^</OneX^>
echo         ^</security^>
echo     ^</MSM^>
echo ^</WLANProfile^>
)

:: Eliminar el perfil anteriormente configurado 
netsh wlan delete profile name="edu.xunta.gal"
:: Importar el perfil
netsh wlan add profile filename="%xmlPath%" user=current
echo Perfil de red "edu.xunta.gal" importado correctamente.
endlocal