Start programs via command-line, but only if not already running
Here is a example using tasklist to check all running applications for a given name.
Otherwise it starts the program. I'm sure you can adapt it to your needs
tasklist /nh /fi "imagename eq notepad.exe" | find /i "notepad.exe" > nul ||
(start notepad.exe)
@echo off
tasklist /FI "IMAGENAME eq outlook.exe" | find /i "outlook.exe"
IF ERRORLEVEL 2 GOTO LOOP2
IF ERRORLEVEL 1 GOTO LOOP1
:LOOP1
start notepad.exe
goto EXIT
:LOOP1
start outlook.exe
goto EXIT
:EXIT
I implemented tasklist into my script and its working like a charm.
Here it is for anyone else having the same questions as I had.
@echo off
pushd
tasklist /nh /fi "imagename eq iexplore.exe" | find /i "iexplore.exe" > nul ||(start Work.vbs)
tasklist /nh /fi "imagename eq outlook.exe" | find /i "outlook.exe" > nul ||(start outlook.exe)
tasklist /nh /fi "imagename eq lync.exe" | find /i "lync.exe" > nul ||(start lync.exe)
tasklist /nh /fi "imagename eq chrome.exe" | find /i "chrome.exe" > nul ||(start chrome.exe)
tasklist /nh /fi "imagename eq VpxClient.exe" | find /i "VpxClient.exe" > nul || runas /savecred /user:"DOMAIN\User_Adm" "C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe"
tasklist /nh /fi "imagename eq mmc.exe" | find /i "mmc.exe" > nul || runas /savecred /user:"DOMAIN\User_Adm" "mmc.exe \"My_Tools.msc\"