Editing .BAT files

  Narayan Adhikari 13:02 06 Mar 2009

Something happened to my system recently that I cannot edit my DOS BAT files anymore. I receive an error message saying: "The file name, directory name or volume label syntax is incorrect." Can anybody please suggest me what to do?

  brundle 15:07 06 Mar 2009

How about right-clicking the .bat file while holding down Shift and select "Open With", choose Notepad.

  Diemmess 15:11 06 Mar 2009

Have you tried opening any .bat files in Notepad?

If you can see the structure of a .bat file which works and compare with one that doesn't, you may have a clue as to what is wrong.

If there is nothing personal on a suspect file then copy and post here so someone can spot the error/errors.

Also please name the OS you are using at the moment.

  MAT ALAN 16:23 06 Mar 2009

click here

could be trojan related...

  Narayan Adhikari 15:23 09 Mar 2009

Following is the .bat file I am using but it does the same with those I have created/saved in notepad. I can open it from within the notepad though. It shows that error if I try to edit from context menu. I also tried with simplest command like cls etc., but no luck!

echo --------------------------------------------
echo Map Drives Script
echo --------------------------------------------
echo Please wait...
echo Mapping drives

net use G: "\\filsrv5\HomeDrive\John.Smith"
net use I: "\\filsrv4\Test"
net use L: "\\filsrv3\Problem"
net use P: "\\filsrv2\Solution"

echo Mapping Completed
net use /PERSISTENT:No
echo Mapped ...

  brundle 16:06 09 Mar 2009

There's an error in the registry entry then; open regedit, navigate to HKEY_CLASSES_ROOT\batfile\shell\edit\command, ensure the string matches the following;

%SystemRoot%\System32\NOTEPAD.EXE %1

  brundle 16:07 09 Mar 2009

If the path you're using to accessing the .bat files contains spaces, you might want to try enclosing the %1 with quotes so that the entire pathname is passed to Notepad.

%SystemRoot%\System32\NOTEPAD.EXE "%1"

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

Alice Saey's mesmerising animation for Dutch singer Mark Lotterman

iPad Pro 10.5in (2017) review

Comment booster votre iPhone ?