I have tried prefixing lines with semicolons, 'REM', etc.. but no matter what when I run my batch file I keep getting "unknown command REM whatever"
If you're talking about cmd.exe
batch files under Windows, you can use:
rem this method or
:: this method.
For bash
and a lot of other UNIX-type shells, you use:
# this method.
I'm pretty certain you're not using cmd.exe
since that would give you an error like:
'rem' is not recognized as an internal or external command,
operable program or batch file.
rather then:
Unknown command ...
If you are using a UNIX-type shell, the #
character is almost certainly what you're after. If you let us know exactly the shell you're using, we can probably help out further.
"REM test" It is not recognized, and it is windows vista. I simply get "rem" output back to my console.
That's entirely normal behavior. Batch files are simply sequences of commands that are run one after another. So every line will get output to the console as if it were typed there.
H:\>echo rem test > test.cmd
H:\>test
yields the output
H:\>rem test
as if I typed rem test
directly to the console.
You can suppress this by either prefixing the line with @
:
@rem test
or by including echo off
in the batch file:
@echo off
rem test
If I put ":: test" and execute it I get back "Test".
Can't reproduce here.
If I put "; test" it recursively executes itself
A semicolon at the start of the line seemingly gets ignored.
you probably created an UNICODE file. These files contain 2 bytes header named BOM which is not shown by any editor but cmd attempts to execute them and fails.
To make sure this is indeed an issue: type any other command at the very beginning of your file and see it throws the same error - for example @echo test
To fix it, just create a new plain text file and copy content of the original file there. then remove the original file and replace it by the newly created one.