code_junkie

Problem with for /f command on Windows XP

Nov 12th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. for /f "tokens=1 delims=: " %A in ('tasklist /FI "IMAGENAME eq python.exe" /NH') do (
  2. If "%A" == "python.exe" (
  3. echo "It's running"
  4. ) Else (
  5. echo "It's not running"
  6. )
  7. )
  8.  
  9. for /F "tokens=1 delims=: " %A in ('tasklist /FI "IMAGENAME eq python.exe" /NH 2^>^&1') do (
  10. if "%A"=="python.exe" (
  11. echo "It's running"
  12. ) else (
  13. echo "It's not running"
  14. )
  15. )
  16.  
  17. @echo off
  18. for /f "tokens=1 delims=: " %%A in ('tasklist /FI "IMAGENAME eq java.exe" /NH') do (
  19. If "%%A" == "java.exe" (
  20. echo "It's running"
  21. ) Else (
  22. echo "It's not running"
  23. )
  24. )
  25.  
  26. @echo off
  27. set found=0
  28.  
  29. for /f "tokens=1 delims=: " %%A in ('tasklist /NH') do (
  30. If /i "%%A" equ "python.exe" (
  31. set found=1
  32. )
  33. )
  34.  
  35. if %found%==1 (
  36. @echo It's running
  37. ) else (
  38. @echo It's not running
  39. )
  40.  
  41. Set RUNNING=False
  42. for /f "tokens=1 delims=: " %%a in ('tasklist /FI "IMAGENAME eq python.exe" /NH 2^>NUL') do (Set RUNNING=True)
  43. If %RUNNING% == True (
  44. @Echo It IS running
  45. ) ELSE (
  46. @Echo It's NOT running
  47. )
Add Comment
Please, Sign In to add comment