Sign in with
Sign up | Sign in
Your question

Odd batch file error (Vista & XP)

Last response: in Windows Vista
Share
July 31, 2012 12:07:57 AM

I'm having a problem with a CMD-style batch file on both Vista and XP machines where the SysVars check out fine (using the SET command at a prompt). PAUSE isn't helping at all, either, in that the CMD window briefly appears, then quickly disappears, when double-clicking the file's icon. Placing the file on my Desktop during testing, I'm having to open a CMD window, change to the Desktop directory and run it directly from the prompt to even see what's going on. Since the referenced ClassicShell.chm file does not exist, I'm expecting to see the echo message.

File contents:

@if exist %programfiles%\Classic Shell\ClassicShell.chm goto Folder_OK
echo CS path different. Email this error message.
pause
exit

Regardless of what I do, this is what is returned:

C:\Users\Me\Desktop>■@
'■@' is not recognized as an internal or external command,
operable program or batch file.

What gives?
July 31, 2012 6:01:39 PM

You have a character before the @ in the file. Create a new text file, do not cut and paste the old contents.
m
0
l
July 31, 2012 6:06:29 PM

Nope. That is not the issue. There isn't a spurious character to the left of the @. I've recreated the file several times from scratch on two machines, both yielding the exact same result.
m
0
l
Related resources
July 31, 2012 6:17:13 PM

I just copied and pasted what you put in here to a new .cmd file, it ran with no errors on XP.

Something is reading a character in front of the @ sign. What if you delete that and just use the "if" as the first thing? Does that run.

BTW, you probably want to put the @ in front of the echo command also so it does not pop up when you run the file.
m
0
l
July 31, 2012 7:41:56 PM

No to your question. It apparently doesn't like the sysvar in the if exist statement, so I've just made it into several lines instead of one, making liberal use of CD changes to accomplish the task.

The echo line is a continuation of the first line. It is what is supposed to be reported to the user (not me) if the file existence test fails.
m
0
l
!