• To loop during 10 seconds monitoring if there is crashing and rebooting whenever Onedrive appear in lockup:
@echo off && setlocal enabledelayedexpansion & cd /d c:\bat
set DataDeHoje=0<nul & echo/ & Title %~n0 & mode con cols=60 lines=03 & >nul chcp 1252
set _key="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
for /f ^delims^=^"^ ^tokens^=2^,* %%i in ('reg query !_key! ^| findstr /lic:"onedrive"') do set "_OneDrive="%%i" %%j"
:inicio
echo/ & color 9F & set "DataDeHoje=!DATE:~0,2!-!DATE:~3,2!-!DATE:~6,4!/!time:~0,5!"&&set "DataDeHoje=!DataDeHoje: =0!"
for /f "tokens=1,* delims= " %%i in ('tasklist /fi "status eq not responding" ^| findstr /v "# ="') do (
echo/%%i %%j | findstr /lic:"OneDrive.exe" >"c:\bat\fiscaliza.txt" && (
color F4 & echo/ & echo/ !DataDeHoje:/= ! Processo: OneDrive.exe travado^^!!.. & taskkill /f /im %%i /t >nul 2>nul
start "" !_OneDrive! && pathping 127.0.0.1 -n -q 1 -p 2500 1>nul & tasklist /fi "status eq running" | findstr /lic:"onedrive.exe" >nul
if "!errorlevel!" equ "0" color 9F & cls & echo/ !DataDeHoje:/= ! Processo: OneDrive.exe reiniciado^^!!..
) || (
cls & echo/ & echo/ !DataDeHoje:/= ! Processo: OneDrive.exe sem travamento^^!!..
)) & timeout /t 10 >nul & goto :inicio
• It is possible to bat/script take these actions. But, I suggest you use the argument /T
, which results in finalize the possible third party proceedings startados/initiated by him also, since, the locking may occur on account of one of these same lawsuits for his sake initialized...
• Just monitor!! Does not assume any action!!
• To loop during 10 seconds monitoring if there is locking Onedrive.exe:
@echo off & setlocal enabledelayedexpansion & cd /d c:\bat
set DataDeHoje=0<nul & echo/ & Title %~n0 & mode con cols=60 lines=03 & >nul chcp 1252
:inicio
echo/ & color 9F & set "DataDeHoje=!DATE:~0,2!-!DATE:~3,2!-!DATE:~6,4!/!time:~0,5!"&&set "DataDeHoje=!DataDeHoje: =0!"
for /f "tokens=1,*delims= " %%i in ('tasklist /fi "status eq not responding" ^| findstr /v "# ="')do (
echo/%%i %%j | findstr /lic:"OneDrive.exe" >"c:\bat\fiscaliza.txt" && (
color F4 & echo/ & echo/ !DataDeHoje:/= ! Processo: OneDrive.exe travado^^!!.. & taskkill /f /im %%i >nul 2>nul
) || (
echo/ !DataDeHoje:/= ! Processo: OneDrive.exe sem travamento^^!!..
)) & timeout /T 10 >nul & cls & goto :inicio
• Just monitor!! Does not assume any action!!
• To loop during 10 seconds monitoring if there is another locking Any other program.exe:
@echo off & setlocal enabledelayedexpansion & cd /d c:\bat
set DataDeHoje=0<nul & echo/ & Title %~n0 & mode con cols=60 lines=03 & >nul chcp 1252
:inicio
echo/ & color 9F & set "DataDeHoje=!DATE:~0,2!-!DATE:~3,2!-!DATE:~6,4!/!time:~0,5!"&&set "DataDeHoje=!DataDeHoje: =0!"
for /f "tokens=1,*delims= " %%i in ('tasklist /fi "status eq not responding" ^| findstr /v "# ="')do (
echo/%%i %%j | findstr /lic:".exe" >"c:\bat\fiscaliza.txt" && (
color F4 & echo/ & echo/ !DataDeHoje:/= ! Processo: %%i travado^^!!.. & taskkill /f /im %%i >nul 2>nul
) || (
echo/ !DataDeHoje:/= ! Todos os processos sem travamento^^!!..
)) & timeout /T 10 >nul & cls & goto :inicio
Speak up, mate. That’s not necessarily a question. The most interesting thing is you ask a question and afterward answer your own question. Everything you need to know about this is in this help center link. Another tip is about formatting. ;)
– LipESprY
It’s not clear, thank you, I edited.
– wagner santos
It seems that you "tried" to turn a "script you want to share" into a question. Reason for a moment: what is your question? If it is "Does it work?" does not follow the scope of the site. You should ask questions about "real problems"... If the goal is to search for "improvements to your script", explicitly define "how and/or what you want to improve".
– LipESprY