Batch file working on XP x32 but not x64

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Chris
Posts: 1
Joined: 25 Aug 2010 12:23

Batch file working on XP x32 but not x64

#1 Post by Chris » 25 Aug 2010 12:42

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

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Batch file working on XP x32 but not x64

#2 Post by orange_batch » 25 Aug 2010 16:49

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

Post Reply