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

LVL 11
bsharathAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
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 http://www.experts-exchange.com/Programming/Languages/Q_25553307.html later today when I free up a little time.  Should be doable.

~bp
0
abt-itCommented:
If it's a service behind the process try "sc stop servicename". To close an applikation, try the command taskkill
0
Bill PrewIT / Software Engineering ConsultantCommented:
Okay, see if this meets your needs.  You will need the pskill utility.

~bp
@echo Off
 
rem Define list of conflicting programs to check for
set "Conflicts=Outlook Communicator SearchIndexer"
 
rem Stop Windows Search service
net stop "Windows Search"
 
rem Kill any of the conflicting processes if running
for %%A in (%Conflicts%) do (
  \\machine\folder\pslist /accepteula %%A >NUL
  if %errorlevel% == 0 (
    \\machine\folder\pskill /accepteula %%A >NUL
  )
)
 
rem Execute the profile manager 
\\machine\folder\profilemgr.exe /logpath=\\machine\folder\logs

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.