Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.
Endpoint Management Community Blog

Detecting Application that is open

Created: 21 Feb 2012 • Updated: 21 Feb 2012
snyderj's picture
0 0 Votes
Login to vote

The company I work for just hired a new CIO. One of the changes he has made affects the way I do installs on users machines with AltirisDS. I was told that I am not to close applications or reboot users' machines. I am hoping this mandate will change but until that happens I have to work within the constraints that have been given to me.

So to deal with the detecting of applications I have come up with a batch file that will detect the application, or applications. The simple idea is to count the open applications, and if the total doesn’t equal zero, then error 1609, “A handle is in an invalid state”. I then went in to the task and add the error to the return code list and set the response to stop, with a failure. I can then run SQL queries against the job, to build a list of users that don’t read their e-mails and let management handle it how they please. I hope this helps anyone else who might be given a similar mandate.

Script template:

 

set count=0
tasklist | findstr /i application1.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i application2.EXE
if %errorlevel%==0 set /a count=%count%+1
if %count%==0 (exit) else (exit 1609)

Detect if “iexplore.exe” is open:

 

set count=0
tasklist | findstr /i iexplorer.EXE
if %errorlevel%==0 set /a count=%count%+1
if %count%==0 (exit) else (exit 1609)

Detect if any of the Office 2007 suite is open:

 

set count=0
tasklist | findstr /i ACCICONS.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i CLVIEW.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i CNFNOT32.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i DSSM.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i EXCEL.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i excelcnv.exe
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i GRAPH.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i MSACCESS.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i MSOHTMED.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i MSQRY32.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i MSTORDB.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i MSTORE.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i ORGCHART.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i OUTLOOK.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i POWERPNT.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i PPTVIEW.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i SCANOST.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i SCANPST.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i SELFCERT.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i SETLANG.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i VPREVIEW.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i WINWORD.EXE
if %errorlevel%==0 set /a count=%count%+1
tasklist | findstr /i Wordconv.exe
if %errorlevel%==0 set /a count=%count%+1
if %count%==0 (exit) else (exit 1609)