Solved Win 7 64 *.bat fail can't even execute echo

sc00b

New member
Local time
8:04 PM
Messages
5
Context : For my blind father, i wrote a *.bat file that would copy audiobook (mp3 files) from a CD to a memory card. Worked fine on his windows XP computer, when he switched to Windows 7 it worked OK after minors adjustments.

New Problem : When I got back home, I was informed that the *.bat no longer work.
After investigations I realise that even REM or ECHO failed to execute (inside the bat file).

I've search the internet for a solution but couldn't find anything :

In order to define my problem, I've made a simple bat with just an echo "hello world", ran it inside cmd got the following error :

Code:
C:\Users\JP\Documents>test.bat

C:\Users\JP\Documents>■e
'■e' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Translated from french it's the well known error message : '■e' not an internal or external command ...

Since echo work fine as a simple command (in CMD) it does not come from a path error.

Can you give me a clue about what is wrong on my father's computer ?


Secondary question :
With windows XP I used to play sound so my father would know what has to be done next. since sndrec32 was removed from windows 7 does anyone know of an other way to play sound ?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom build
OS
Windows 7 64
For first issue, please check path variable. Just type PATH in cmd. Please post result.
I would scan for malware just in case.

As for second issue, you can use something like this in your bat file.
http://superuser.com/questions/101974/play-a-sound-maybe-wav-from-windows-line-command said:
powershell -c (New-Object Media.SoundPlayer "C:\Windows\Media\notify.wav").PlaySync();
 

My Computer

Computer type
PC/Desktop
OS
Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
Other Info
"The scale icon at the top right of a post or tutorial is how you can give rep to the member."
May I see the source of your batch file?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate x64 Service Pack 1
CPU
AMD Athlon II x4 Propus 2.9 GHz
Motherboard
ASRock N68C-GS FX
Memory
2 x 4GB Corsair XMS 3 DDR3 -1600 CL9
Graphics Card(s)
AMD Radeon HD 5850 1GB GDDR5
Sound Card
On-board 6-Channel HD Audio
Monitor(s) Displays
18' LG Flatron E1942TC-BN on DVI, 18' Chimei 95ND on HDMI
Screen Resolution
1366 x 768 x 2
Hard Drives
1 x 500 GB Seagate
1 x 1 TB Western Digital Caviar Green
1 x 1 TB Hitachi Touro Mobile USB 3
PSU
Seasonic S12II 520W
Case
Generic with Cable Management
Cooling
Deep Cool Gammaxx 200
Keyboard
Dragonwar Desert Eagle
Mouse
Logitech B85
Internet Speed
5Mb/s DL, 0.9Mb/s UL
Antivirus
ESET Nod32
Browser
Google Chrome 64 Bit
Other Info
LG G4 H818P - Rooted with Xposed Framework
@Neutron16
Thank you for taking the time to look into it.
As stated before I assumed the path was ok since echo worked with CMD and not in the *.bat, on the other hand I have no idea what errors to look for in the path, so here it is
Code:
C:\>path
PATH=c:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
@oreo

at the moment even at *.bat with just this line is not working
Code:
ECHO "hello world"
My main program is still a work in progress (not very clean, and commented in french)
Code:
REM LecteurCD selection du lecteur d'origne des MP3
set LecteurCD=b
REM Destination Destination des livres 
set Destination=g:\$VROtherBooks\

set var="NOK"


for /f "tokens=*" %%i in ('dir /b /A:D %LecteurCD%:\') do (

set var="OK"

%LecteurCD%:
cd %LecteurCD%:/%%i



if '%%i' equ "mp3" GOTO bad
if "%%i" equ "Mp3" GOTO bad
if "%%i" equ "MP3" GOTO bad

set Livre=%%i

echo config livre = %livre%
goto Copy
)

if %var% equ "NOK" GOTO bad


:eof
REM Start /min sndrec32 /play /close %SystemRoot%\Media\tada.wav
Exit 5

:bad
title entrez titre du livre
REM Start /min sndrec32 /play /close %SystemRoot%\Media\ringin.wav
%LecteurCD%:
set /p Livre= Titre du livre 
echo titre du livre %Livre%
goto Copy

:Copy 
title Copie livre %%i
echo Copy [%Livre%] To ["%Destination%%Livre%"]


REM Start /min sndrec32 /play /close %SystemRoot%\Media\notify.wav
xcopy /v /y /I *.mp3 "%Destination%%Livre%"

goto eof

Other informations :
the batch was working at Xmas, no new program installed but some update were done.
I haven't confirmed that the errors are the same but some other people using my script (Variables allow me to quickly give it to other users) report suddently not being able to use the script.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom build
OS
Windows 7 64
Well, it's certainly a lot more complicated than I imagined.

In any case, this output is somewhat strange to me.

Code:
C:\Users\JP\Documents>■e
'■e' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.

It seems the command is not properly executed. Here's a crazy idea, can you try this Hello World batch attached to this post?

I'm trying to figure out if it has anything to do with the encoding of your batch file.
 

Attachments

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate x64 Service Pack 1
CPU
AMD Athlon II x4 Propus 2.9 GHz
Motherboard
ASRock N68C-GS FX
Memory
2 x 4GB Corsair XMS 3 DDR3 -1600 CL9
Graphics Card(s)
AMD Radeon HD 5850 1GB GDDR5
Sound Card
On-board 6-Channel HD Audio
Monitor(s) Displays
18' LG Flatron E1942TC-BN on DVI, 18' Chimei 95ND on HDMI
Screen Resolution
1366 x 768 x 2
Hard Drives
1 x 500 GB Seagate
1 x 1 TB Western Digital Caviar Green
1 x 1 TB Hitachi Touro Mobile USB 3
PSU
Seasonic S12II 520W
Case
Generic with Cable Management
Cooling
Deep Cool Gammaxx 200
Keyboard
Dragonwar Desert Eagle
Mouse
Logitech B85
Internet Speed
5Mb/s DL, 0.9Mb/s UL
Antivirus
ESET Nod32
Browser
Google Chrome 64 Bit
Other Info
LG G4 H818P - Rooted with Xposed Framework
@oreo27
You seem to be on to something since your *.bat file run OK, but when I copy/paste the command into my *.bat file it give me the error message.

I'm using a simple notepad to do it so I have no idea where the encoding/saving problem come from :/

As for my main program, it's probably not the most efficient way to do things, but it grew with every case I encounder, in order to make it very simple for the user : this sound mean type the title, this one mean it's copying and the last sound mean copy finished, next book please ^^
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom build
OS
Windows 7 64
@oreo27
You seem to be on to something since your *.bat file run OK, but when I copy/paste the command into my *.bat file it give me the error message.

I'm using a simple notepad to do it so I have no idea where the encoding/saving problem come from :/

As for my main program, it's probably not the most efficient way to do things, but it grew with every case I encounder, in order to make it very simple for the user : this sound mean type the title, this one mean it's copying and the last sound mean copy finished, next book please ^^

Well, to be honest, I think it has to do with Windows' language settings. But this is just purely speculation and if someone else can jump in and explain it, that'd be great.

I personally use Notepad++ Home for coding in batch. The default options work fine for me. Can you try using that and see if you end up with the proper result?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate x64 Service Pack 1
CPU
AMD Athlon II x4 Propus 2.9 GHz
Motherboard
ASRock N68C-GS FX
Memory
2 x 4GB Corsair XMS 3 DDR3 -1600 CL9
Graphics Card(s)
AMD Radeon HD 5850 1GB GDDR5
Sound Card
On-board 6-Channel HD Audio
Monitor(s) Displays
18' LG Flatron E1942TC-BN on DVI, 18' Chimei 95ND on HDMI
Screen Resolution
1366 x 768 x 2
Hard Drives
1 x 500 GB Seagate
1 x 1 TB Western Digital Caviar Green
1 x 1 TB Hitachi Touro Mobile USB 3
PSU
Seasonic S12II 520W
Case
Generic with Cable Management
Cooling
Deep Cool Gammaxx 200
Keyboard
Dragonwar Desert Eagle
Mouse
Logitech B85
Internet Speed
5Mb/s DL, 0.9Mb/s UL
Antivirus
ESET Nod32
Browser
Google Chrome 64 Bit
Other Info
LG G4 H818P - Rooted with Xposed Framework
OK seems to be working. Thank you very much Oreo27 for the quick response, now I just need to add the sound (thanks Neutron16).

I will post the *.bat once it's completed if you recon it might help someone, someday.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom build
OS
Windows 7 64
OK seems to be working. Thank you very much Oreo27 for the quick response, now I just need to add the sound (thanks Neutron16).

I will post the *.bat once it's completed if you recon it might help someone, someday.

No worries. Glad it works. :)
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate x64 Service Pack 1
CPU
AMD Athlon II x4 Propus 2.9 GHz
Motherboard
ASRock N68C-GS FX
Memory
2 x 4GB Corsair XMS 3 DDR3 -1600 CL9
Graphics Card(s)
AMD Radeon HD 5850 1GB GDDR5
Sound Card
On-board 6-Channel HD Audio
Monitor(s) Displays
18' LG Flatron E1942TC-BN on DVI, 18' Chimei 95ND on HDMI
Screen Resolution
1366 x 768 x 2
Hard Drives
1 x 500 GB Seagate
1 x 1 TB Western Digital Caviar Green
1 x 1 TB Hitachi Touro Mobile USB 3
PSU
Seasonic S12II 520W
Case
Generic with Cable Management
Cooling
Deep Cool Gammaxx 200
Keyboard
Dragonwar Desert Eagle
Mouse
Logitech B85
Internet Speed
5Mb/s DL, 0.9Mb/s UL
Antivirus
ESET Nod32
Browser
Google Chrome 64 Bit
Other Info
LG G4 H818P - Rooted with Xposed Framework
if someone else can jump in and explain it, that'd be great
I was able to recreate the error. That happens when you save your bat file in notepad in UTF-8 encoding instead ANSI. You need to save it again in ANSI.

Notepad would ask for encoding change if it finds that file contains any letters with accents for example (é, è, ê etc.).
 

My Computer

Computer type
PC/Desktop
OS
Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
Other Info
"The scale icon at the top right of a post or tutorial is how you can give rep to the member."
if someone else can jump in and explain it, that'd be great
I was able to recreate the error. That happens when you save your bat file in notepad in UTF-8 encoding instead ANSI. You need to save it again in ANSI.

Notepad would ask for encoding change if it finds that file contains any letters with accents for example (é, è, ê etc.).

That's strange. The default encoding for Notepad++ is UTF-8 without BOM. Yet, if I save the batch file, it still works okay.

But, If I change it to UTF-8, I'm also able to reproduce the error.

Code:
C:\Users\Rokn\Documents>@ECHO Test
'@ECHO' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
I never did understand these options. Lol.

I only learned about these because some batch files (.txt files, actually) were not running properly in game The Elder Scrolls V: Skyrim - Wikipedia, the free encyclopedia.

Just a bit of an edit:

From my understanding, I think that UTF-8 adds some hidden characters that identify it as such in terms of encoding. These characters are passed on to the batch file which break the first command. Other commands should still function. Notepad++'s option of removing the BOM fixes the problem.

The source can be found here - http://stackoverflow.com/questions/2223882/whats-different-between-utf-8-and-utf-8-without-bom
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate x64 Service Pack 1
CPU
AMD Athlon II x4 Propus 2.9 GHz
Motherboard
ASRock N68C-GS FX
Memory
2 x 4GB Corsair XMS 3 DDR3 -1600 CL9
Graphics Card(s)
AMD Radeon HD 5850 1GB GDDR5
Sound Card
On-board 6-Channel HD Audio
Monitor(s) Displays
18' LG Flatron E1942TC-BN on DVI, 18' Chimei 95ND on HDMI
Screen Resolution
1366 x 768 x 2
Hard Drives
1 x 500 GB Seagate
1 x 1 TB Western Digital Caviar Green
1 x 1 TB Hitachi Touro Mobile USB 3
PSU
Seasonic S12II 520W
Case
Generic with Cable Management
Cooling
Deep Cool Gammaxx 200
Keyboard
Dragonwar Desert Eagle
Mouse
Logitech B85
Internet Speed
5Mb/s DL, 0.9Mb/s UL
Antivirus
ESET Nod32
Browser
Google Chrome 64 Bit
Other Info
LG G4 H818P - Rooted with Xposed Framework
At last I've finished my script :

Code:
REM LecteurCD selection du lecteur d'origne des MP3
set LecteurCD=b
REM Destination Destination des livres 
set Destination=g:\$VROtherBooks\

set var="NOK"


for /f "tokens=*" %%i in ('dir /b /A:D %LecteurCD%:\') do (

set var="OK"

%LecteurCD%:
cd %LecteurCD%:/%%i



if '%%i' equ "mp3" GOTO bad
if "%%i" equ "Mp3" GOTO bad
if "%%i" equ "MP3" GOTO bad

set Livre=%%i

echo config livre = %livre%
goto Copy
)

if %var% equ "NOK" GOTO bad


:eof
REM Start /min sndrec32 /play /close %SystemRoot%\Media\tada.wav
powershell -c (New-Object Media.SoundPlayer "%SystemRoot%\Media\'Windows shutdown.wav'").PlaySync();
Exit 5

:bad
title entrez titre du livre
REM Start /min sndrec32 /play /close %SystemRoot%\Media\ringin.wav
powershell -c (New-Object Media.SoundPlayer "%SystemRoot%\Media\'Windows print complete.wav'").PlaySync();
%LecteurCD%:
set /p Livre= Titre du livre 
echo titre du livre %Livre%
goto Copy

:Copy 
title Copie livre %%i
echo Copy [%Livre%] To ["%Destination%%Livre%"]


REM Start /min sndrec32 /play /close %SystemRoot%\Media\notify.wav
powershell -c (New-Object Media.SoundPlayer "%SystemRoot%\Media\'Windows balloon.wav'").PlaySync();

xcopy /v /y /I *.mp3 "%Destination%%Livre%"

goto eof

Notes :
I was not able to play sound from %SystemRoot%\Media\Sonata\* because it seems it wasn't a "PCM Sound"

Is it possible to declare powershell object at he begining of the script and use it later on to play the sound ? Because now the script run well enough, but the sound playing cause a 2-3 second lag...

Once again thank you very much for the help... Futur modification will wait for my next visit home :p
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom build
OS
Windows 7 64
Back
Top