Friday, May 24, 2024

Keep a program running at all times - if a program closes, have it restart automatically in Windows

First, create a batch file to monitor the program and restart it-

@echo off
setlocal enabledelayedexpansion

set EXE_PATH="C:\path\to\MyProgram.exe"
set EXE_NAME=MyProgram.exe

:start_program
start "" %EXE_PATH%
echo Program started. Monitoring...

:monitor
REM Check if the program is running
tasklist /FI "IMAGENAME eq %EXE_NAME%" 2>NUL | find /I "%EXE_NAME%" >NUL
if "%ERRORLEVEL%"=="0" (
    REM Program is running, wait and check again
    timeout /t 1 >nul
    goto monitor
)

REM Program is not running, restart it
echo Program closed. Restarting...
goto start_program



Next, create a VBS script to run the batch file-

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /c C:\path\to\monitor.bat", 0, False  




Finally, set the vbs script to run at windows startup-

Press Win + R to open the Run dialog.
Type shell:startup and press Enter. This opens the Startup folder.
Create a shortcut to the VBS script in the Startup folder.


Adam Cushing
www.adamcushing.com

Tuesday, May 21, 2024

ScreenConnect / ConnectWise Control not working on RHEL/Oracle Linux- service runs but doesn't work or garbled screen.

I recently had a problem where I loaded ScreenConnect for remote access to a RHEL server. I imagine this is similar for other distros, Centos, Rocky. It has happened on Oracle Linux.




First thing you need is Java. The stupid thing is, it will install without it. But it won't work.
sudo yum install java-1.8.0-openjdk


Then you'll need to disable  Wayland-
sudo nano /etc/gdm/custom.conf

Uncomment this-
WaylandEnable=false

Check the service-
systemctl --type=service

Start or Restart the 'Connectwisexxx"

systemctl status ConnectWisexxx
systemctl start/stop/restart ConnectWisexxx

If you still have issues, check the logs-
/var/logs/messages
/var/logs/connectwise***

Adam Cushing
www.adamcushing.com