Link to home
Start Free TrialLog in
Avatar of Glenn M
Glenn MFlag for United States of America

asked on

Batch script - If process exists then exit

Hey Experts,

I have tried to create a batch script, but using the tasklist, it gives me processes for all users, this won't work.

I need to run a per user script on a terminal server, here is what I need:
I need a batch file that will check to see if a process if running for that user. If exists, then exit. If it doesn't exists, then start....

Here is what I have thus far:


@echo off
 
if tasklist /FI "IMAGENAME eq CPOPM06.exe" | find /i "CPOPM06.exe" && set PROCEXIST=YES
 
else
 
set %PROCEXIST%=NO
 
goto IFSTATE
 
:IFSTATE
if /I "%PROCEXIST%"=="YES" goto :EXEC
if /I "%PROCEXIST%"=="NO" goto EXIT
 
:EXEC
start http://servername/centricityps
exit

:EXIT
exit
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

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
SOLUTION
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
Avatar of Glenn M

ASKER

Both scripts accomplish the goal!