Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Script that checks for processes and stops. Can it stop the processes if any opened.

Hi,

Script that checks for processes and stops. Can it stop the processes if any opened.
Can anyone help changing the script to stop any process thats in the list.

Regards
Sharath
@Echo Off

net stop "Windows Search"

REM Delete Exisitng Temp File
if exist %TEMP%\proc.txt del %TEMP%\proc.txt /q

REM Clear Process Counter
set /a proc=0

\\dev\profilemanager\pslist /accepteula > %TEMP%\proc.txt

Echo Checking for Outlook

find /i "Outlook" %TEMP%\proc.txt 

if not errorlevel 1 Set /a proc=%proc%+1

Echo Checking for Communicator

find /i "communicator" %TEMP%\proc.txt 

if not errorlevel 1 Set /a proc=%proc%+2

Echo Checking for Desktop Search

find /i "searchindexer" %TEMP%\proc.txt 

if not errorlevel 1 Set /a proc=%proc%+3

if %proc%==1 Goto OutlookFound

if %proc%==2 Goto CommFound

if %proc%==3 Goto SearchFound

if %proc%==4 Goto OutlookSearchFound

if %proc%==5 Goto CommSearchFound

if %proc%==6 Goto OutlookCommSearchFound

Echo No Process running

Echo Starting Profile Manager

:PROFMAN

\\dev\profilemanager\profilemgr.exe /logpath=\\dev\profilemanager\logs1

Goto End

:OutlookFound

cls

Echo Outlook is Running. Please Close Outlook before running batch file again.

Pause.

Goto End

:CommFound

cls

Echo Communicator is Running. Please Close Communicator before running batch file again.

Pause.

Goto End

:SearchFound

cls

Echo Desktop Search is Running. Please Close Desktop Search before running batch file again.

Pause.

Goto End

:OutlookSearchFound

cls

Echo Outlook and Desktop Search are Running. Please Close these before running batch file again.

Pause.

Goto End

:CommSearchFound

cls

Echo Communicator and Desktop Search are Running. Please Close these before running batch file again.

Pause.

Goto End

:OutlookCommSearchFound

cls

Echo Outlook, Communicator and Desktop Search are Running. Please Close these before running batch file again.

Pause.

Goto End

:End
del %TEMP%\proc.txt /q

Pause

Open in new window

Avatar of Bill Prew
Bill Prew

I'm busy today repair computers affected by the McAfee problem yesterday, but will add that logic to my improved version of this code posted in earlier question https://www.experts-exchange.com/questions/25553307/Can-anyone-help-mw-understand-what-this-batch-script-does.html later today when I free up a little time.  Should be doable.

~bp
If it's a service behind the process try "sc stop servicename". To close an applikation, try the command taskkill
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial