Page 1 of 1

Batch file working on XP x32 but not x64

Posted: 25 Aug 2010 12:42
by Chris
Logic of this script:

1. Check if notepad.exe process is running
2. If running go to end
3. Else play the sound and start notepad.exe

This script works on Windows XP Pro x32 but when I try to run the job on a version of XP Pro x64 it plays the sound every time even if the process is running, but doesn't restart the process. So even though it says go to end and bypass playing the sound it still does every time the script is executed.

Any help would be appreciated.....

tasklist /FI "IMAGENAME eq notepad.exe" /FO CSV > search.log

FOR /F %%A IN (search.log) DO IF %%~zA EQU 0 GOTO end

start "" /min mplayer2 "c:\Windows\Media\error.wav" /play /close

start notepad.exe

:end

del search.log

Re: Batch file working on XP x32 but not x64

Posted: 25 Aug 2010 16:49
by orange_batch
Sounds odd. Perhaps tasklist behaves differently under x64, or the path to notepad isn't known to DOS/start.

No need for search.log though.

Code: Select all

for /f "skip=2" %%x in ('tasklist /fi "imagename eq notepad.exe" /fo csv 2^>nul') do exit
start "" /min mplayer2 "c:\Windows\Media\error.wav" /play /close
start notepad.exe