Inicio › Foros › Sistemas operativos › Windows › Hacer script MS-DOS para obtener PID proceso matar e iniciar servicio › Respuesta a: Hacer script MS-DOS para obtener PID proceso matar e iniciar servicio
09/06/2017 a las 09:56
#1386
alonsojpd
Superadministrador
Puedes hacerlo con el siguiente script MS-DOS:
MS DOS
1 2 3 4 5 6 7 8 |
@ echo off for /f "tokens=2 delims=," %%a in ('tasklist /svc /FO csv ^| findstr /C:TermService') do set PID=%%a if not defined PID echo NO se ha encontrado el proceso TermService.& exit /b 1 taskkill /F /PID %PID% timeout /T 10 net start termservice timeout /T 10 shutdown -r -f -t 06 |
Ten en cuenta que no se comprueba casi nada, sólo si se ha obtenido el PID del proceso termservice. Puedes mejorar el script, pero te servirá como guía.