hi
hope you guys r enjoying weekend.
can anyone help me with a batch script to check only one application at a time
ie
notepad.exe
calc.exe
wordpad.exe
mspaint.exe
if notepad.exe is running then the other three should not run.
the same condition for the other 3.
thanks
Stop programs from running
Moderator: DosItHelp
Stop programs from running
Last edited by Squashman on 10 Sep 2017 12:24, edited 1 time in total.
Reason: MOD EDIT: Added Descriptive thread title.
Reason: MOD EDIT: Added Descriptive thread title.
Re: please help
Could you please try to better describe what it is you want to do instead of what you don't want to do.
Your question as I see it:
If any one of notepad.exe, calc.exe, wordpad.exe or mspaint.exe are running start none of them else start one of them.
Question raised:
If none of them are running which one of the four do you want run?
Your question as I see it:
If any one of notepad.exe, calc.exe, wordpad.exe or mspaint.exe are running start none of them else start one of them.
Question raised:
If none of them are running which one of the four do you want run?
Re: please help
You could filter the tasks using FINDSTR and count using FIND.
Note that the process name of the calculator changed on Win10. It's now calculator.exe.
Steffen
Code: Select all
@echo off &setlocal
for /f %%i in (
'tasklist /nh^|findstr /lbi "notepad.exe calc.exe wordpad.exe mspaint.exe"^|find /c /v ""'
) do set "cnt=%%i"
echo %cnt% of 4 running.
pause
Note that the process name of the calculator changed on Win10. It's now calculator.exe.
Steffen
Re: please help
Sounds like you are trying to block applications from running if some other app is running. I wouldn't recommend trying to do this with a batch file.