Is it possible to make 1 batch file to open a program like magnify if it's close or close it if it's open? thank you
@echo off
tasklist /FI "IMAGENAME eq magnify.exe" 2>NUL | find /I /N "magnify.exe">NUL
if "%ERRORLEVEL%"=="0" (goto running) else (goto not)
:running
taskkill /im magnify.exe
goto end
:not
start magnify.exe
:end
tasklist /FI "IMAGENAME eq magnify.exe" 2>NUL | find /I /N "magnify.exe">NUL
if "%ERRORLEVEL%"=="0" (goto running) else (goto not)
:running
taskkill /im magnify.exe
goto end
:not
start magnify.exe
:end
@echo OFF
set Lupe=Magnify.exe
TaskList /FI "IMAGENAME eq %Lupe%" 2>NUL | Find /I /N "%Lupe%">NUL
if "%errorlevel%" == "0" (
taskkill /IM %Lupe%
goto ende
) else (
start "%Lupe%" "%windir%\system32\%Lupe%"
goto ende
)
:ende
tasklist | find /i "magnify.exe">nul && Taskkill /F magniy.exe
@echo OFF
tasklist |find "magnify.exe" >nul
if %errorlevel% == 0 (
taskkill /IM "magnify.exe"
goto ende
) else (
start "%windir%\system32\magnify.exe"
goto ende
)
:ende
@echo OFF
set Lupe=magnify.exe
tasklist |find "%Lupe%" >nul
if %errorlevel% == 0 (
start "%Lupe%" "%windir%\system32\%Lupe%"
goto ende
) else (
taskkill /IM "%Lupe%"
goto ende
)
:ende
@echo OFF
set Lupe=magnify.exe
TaskList /FI "%Lupe% eq RUNNING" 1>NUL | Find "%Lupe%" 2>NUL
if %errorlevel% == 2 (
taskkill /IM "%Lupe%"
goto ende
) else (
start "%Lupe%" "%windir%\system32\%Lupe%"
goto ende
)
:ende
@echo OFF
set Lupe=magnify.exe
TaskList /FI "IMAGENAME eq %Lupe%" 2>NUL | Find "%Lupe%" >NUL
if %errorlevel% == 2 (
taskkill /IM "%Lupe%"
goto ende
) else (
start "%Lupe%" "%windir%\system32\%Lupe%"
goto ende
)
:ende
@echo OFF
set Lupe=Magnify.exe
TaskList /FI "IMAGENAME eq %Lupe%" 2>NUL | Find "%Lupe%" >NUL
if %errorlevel% == 1 (
start "%Lupe%" "%windir%\system32\%Lupe%"
goto ende
) else (
taskkill /IM "%Lupe%"
goto ende
)
:ende
[code="xml"]@echo OFF
set Lupe=Magnify.exe
TaskList /FI "IMAGENAME eq %Lupe%" 2>NUL | Find /I /N "%Lupe%">NUL
if "%errorlevel%" == "0" (
taskkill /IM %Lupe%
goto ende
) else (
start "%Lupe%" "%windir%\system32\%Lupe%"
goto ende
)
:ende
@echo off
tasklist /FI "IMAGENAME eq magnify.exe" 2>NUL | find /I /N "magnify.exe">NUL
if "%ERRORLEVEL%"=="0" (goto running) else (goto not)
:running
taskkill /im magnify.exe
goto end
:not
start magnify.exe
:end
@echo off
start C:\WINDOWS\system32\schtasks.exe /run /tn elevated_ADAD_potkseDmihcAsresUC