@ECHO OFF ECHO ************************************************ ECHO * * ECHO * CONECTANDO UNIDAD S: AL CLOUD DE EDUCAMADRID * ECHO * * ECHO ************************************************ REM Obtener página de códigos activa: FOR /F "usebackq tokens=2 delims=:" %%A IN (`CHCP`) DO SET codepage=%%A REM Mostrar los mensajes en la página de códigos adecuada. REM Usar UNO de estos valores: REM 65000 si el script se guarda como texto unicode REM 65001 si se guarda como texto UTF-8 REM 850 si se guarda como texto MS-DOS CHCP 65001 ECHO Estado del servicido Webclient: SC QUERY webclient |FIND "RUNNING" IF ERRORLEVEL 1 GOTO :servicioInactivo :probar SET /P UsuarioEM=Escriba su nombre de usuario: NET USE S: \\cloud.educa.madrid.org@SSL\remote.php\dav\files\%UsuarioEM% /user:%UsuarioEM% * /persistent:no IF ERRORLEVEL 1 GOTO :error COLOR 47 CLS ECHO Sesión abierta en unidad S: :cerrarSesion ECHO Pulse cualquier tecla para cerrar sesión PAUSE NET USE /DELETE S: IF ERRORLEVEL 1 GOTO :cerrarSesion COLOR 07 GOTO :fin :servicioInactivo ECHO El servicio webclient está deshabilitado. ECHO Para activarlo debe tener privilegios de ADMINISTRADOR. ECHO ¿Intentar activarlo? (S=Sí, N=No) SET /P enableWebClient=(S=Sí, N=No) IF enableWebClient.==s. GOTO :intentaActivar IF enableWebClient.==S. GOTO :intentaActivar IF enableWebClient.==y. GOTO :intentaActivar IF enableWebClient.==Y. GOTO :intentaActivar IF enableWebClient.==N. GOTO :probardisable REM comparación de palabras sin tener en cuenta mayúsculas ECHO "*Y*S*Si*Sí*Yes*" | FIND /i "*%enableWebClient%*" IF %errorlevel%.==0. GOTO :intentaActivar ECHO "*N*No*" | FIND /i "*%enableWebClient%*" if %errorlevel%==0 GOTO :probardisable GOTO :servicioInactivo :intentaActivar POWERSHELL START -Verb RunAs NET -ArgumentList { START webclient } IF ERRORLEVEL 0 GOTO :probar GOTO :probar :Error REM errorlevel 2=host no encontrado / servicio no activo. REM (es decir, no podemos usar ERRORLEVEL REM para determinar la causa del error). COLOR 47 ECHO ERROR %ERRORLEVEL%. ECHO Posibles causas: ECHO -Nombre de usuario y contraseña erróneos. ECHO -Servicio Cliente web no ejecutándose (NET START WEBCLIENT). ECHO -Fallo en la conexión de red ECHO Waiting 30 seconds... ECHO OFF SET /A endTime=( %time:~-5,2% + 30 ) %% 60 @echo off echo Esperando 30 segundos... rem Lo siguiente es necesario porque rem para SET, los números que empiezan rem por 0 son octales. rem 1- Obtén el segundo y añade espacio rem antes. set endTime= %time:~-5,2% rem 2- Elimina cero tras espacio set endTime=%endTime: 0= % rem 3- Opera aritméticamente set /A endTime=( %endTime% + 30 ) %% 60 echo %endTime% rem 4- Recupera el cero for /L %%a in (0;1;9) do if "%endTime%"=="%%a" set endTime=0%%a rem 5- Espera hasta que el valor coincida con rem el segundo actual. :repeat rem aunque use EQU he tenido que recuperar el cero, porque rem 05 EQU 5, pero 08 NOT EQU 0. if %time:~-5,2% EQU %endTime% goto :fin goto :repeat GOTO :repetir :fin COLOR 07 if not %codepage%.==. CHCP %codepage%