10-03-22 02:22 PM
11-03-22 06:19 PM
@echo off
setlocal EnableExtensions
setlocal EnableDelayedExpansion
set RR_WINDOW_TITLE="Window Title: Blue Prism - Resource PC"
rem Loop through any instances of 'automate.exe'.
for /f "tokens=*" %%i in ('tasklist /FI "imagename eq automate.exe" /fo list /v ^| find "Window Title:"') do (
rem Get the current window title.
set CURRENT_WINDOW_TITLE=%%i
if "!CURRENT_WINDOW_TITLE!"=="" (
rem Not running, or not booted up yet, do nothing
) else (
rem Extract the base portion of the window title. This allows us to bypass the specific port number
rem and software version information contained in the window title of a properly running Automate.exe instance.
set STRIPPED_TITLE=!CURRENT_WINDOW_TITLE:~0,38!
rem Perform a string comparison of the current window title and the standard runtime resource title defined above.
echo %RR_WINDOW_TITLE% | findstr /C:"!STRIPPED_TITLE!" 1>nul
rem The comparison above will set the value of the errorlevel obect. If the errorlevel is 1, there was no match and
rem we found a Automate.exe window displaying an error message. If the errorlevel is 0, we had a match and found a
rem properly running and connected Automate.exe window.
if errorlevel 1 (
rem Failed to connect on first try, kill automate.exe, wait 5 secs, and start it again.
taskkill /im automate.exe
timeout 5 >nul
start "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\rr_startup.bat"
) else (
rem Running normally, disable the scheduled task that runs this batch script
schtasks.exe /Change /TN "Run Check Automate" /DISABLE
)
)
)
endlocal
endlocal
12-03-22 03:35 AM
15-03-22 01:34 PM
15-03-22 01:47 PM