Is there a way (via scripting of course) to check if a specified process is running, w/o using third-party programs (I mean programs not built in Windows)? And return 1 if it is running, 0 else?
Thanks!
How to determine if a specific process is running?
-
nas8e9
- Posts: 2232
- Joined: 21 Jun 2008 14:50
Re: How to determine if a specific process is running?
This StackOverflow thread seems promising?Huidong wrote:Is there a way (via scripting of course) to check if a specified process is running, w/o using third-party programs (I mean programs not built in Windows)? And return 1 if it is running, 0 else?
Thanks!
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: How to determine if a specific process is running?
Thanks.
So far I havewhich works OK, but how to let it return an errorlevel value? I know if found, errorlevel==0, if not found, errorlevel==1
How to get the value after executing the run command?
So far I have
Code: Select all
run "cmd /k tasklist /fi ""Imagename eq notepad.exe"" | find ""notepad.exe""", "C:\";How to get the value after executing the run command?
-
nas8e9
- Posts: 2232
- Joined: 21 Jun 2008 14:50
Re: How to determine if a specific process is running?
It's getting really kludgy, but I'd have the batch file write a result code to a temporary text file and have XYplorer read and then delete that file.Huidong wrote:Thanks.
So far I havewhich works OK, but how to let it return an errorlevel value? I know if found, errorlevel==0, if not found, errorlevel==1Code: Select all
run "cmd /k tasklist /fi ""Imagename eq notepad.exe"" | find ""notepad.exe""", "C:\";
How to get the value after executing the run command?
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: How to determine if a specific process is running?
That's not the major issue to me. Could you write the %errorlevel% value to a file? I can do echo %errorlevel% after find, and get the right value. But how to output that value to xy?
-
nas8e9
- Posts: 2232
- Joined: 21 Jun 2008 14:50
Re: How to determine if a specific process is running?
Huidong wrote:That's not the major issue to me. Could you write the %errorlevel% value to a file? I can do echo %errorlevel% after find, and get the right value. But how to output that value to xy?
Code: Select all
echo %errorlevel% > %Temp%\Status.txtIn general, this stuff is very easy to find with Google (as alluded to earlier, this isn't exactly new/unknown territory...
XYplorer Beta Club