2
I basically want to combine the following sets of commands. In other words I need to check to see if any executable that exists in c:\apps is running, and if any are, to kill them. Once these commands are complete, I will do a robocopy to update files in c:\apps. This script will be deployed with SCCM. Because of this, I need all commands to return errorlevel 0, otherwise it will report the deployment as failed.
tasklist 2>NUL | find /I /N "processname.exe">NUL
if "%ERRORLEVEL%"=="0" taskkill /f /im processname.exe
and
for /r c:\apps\ %%G in (*.exe) do taskkill /F /IM %%~nxG
2Welcome to SU! What's your question exactly? What problem are you running into while trying to accomplish your stated goal? – Ƭᴇcʜιᴇ007 – 2014-03-13T14:48:41.800
Also, keep in mind that while an executable is called
launchme.exe
, when in memory the image name might be different.launchme.exe
may just be a wrapper to other libraries/executables which need to be loaded before the actual UI is displayed. In other words, don't rely in the executable name alone. – JSanchez – 2014-03-13T15:56:46.163Ultimately I want to be able to copy some files to the c:\apps folder. In order to do that, the executables that exist in c:\apps all have to be killed off. Good point on the wrappers, but in my case, it's not a concern. Also, sidenote, the reason I want errorcode 0 is so that the deployment in SCCM won't report as "failed". – Nathan – 2014-03-14T20:01:45.600