I'm trying to make a batch script to kill LGHub after it launches on startup (LGHub needs to load in order to start services that run my mouse's macros/binds, but I don't need the full program/window sitting open on my desktop after those services launch). According to directions I found to launch the batch file at startup, I made a shortcut to the file and threw the shortcut in the Windows Startup
folder.
Now, I've never written a batch script before, but from my research and the code taken from other threads, this should do the job. If not, well, A) there's that, but B) the file seems to launch on startup, but then close immediately, instead of waiting like it should.
My current script is
@ECHO off
set /A counter=0
:while
IF %counter% le 30 (
tasklist /FI "IMAGENAME eq lghub.exe" 2>NUL | find /I /N "lghub.exe">NUL
IF "%ERRORLEVEL%"=="0" (
taskkill /im "lghub.exe"&exit
) ELSE (
set /A counter+=1
SLEEP 1
GOTO :while
)
)
echo "Could not kill LG Hub after 30 seconds."&exit