- If the variable is not defined it will be interpreted as nothing but a literal expression (e.g. "test %novariable%.bat"). Such file names won't cause any problems.
- If the variable is predefined (e.g. "test %path%.bat" or "test %prompt%.bat") the variables are expanded. That causes error messages or funny side effects.
Lets talk about the latter where I can imagine two possibilities.
- The variable value contains characters that are invalid in file names (e.g. a colon). In that case the cmd complains about wrong syntax.
- The variable contains a value that is valid for file names. In that case the cmd will probably complain that it isn't able to find the file.
BUT what happens if the file exists? Quite a good question. It depends ...

Lets create two batch files in the same directory. First one named "%prompt%.bat", the second "$P$G.bat" (where $P$G is the default value of %prompt%, you should change the name if it differs).
Some cases:
- "%prompt%.bat" is empty, don't care about the content of "$P$G.bat":
The OS checks whether a batch file is empty or not. You would get an error message that the file isn't a valid application as soon as you double click on "%prompt%.bat".
- "%prompt%.bat" contains at least one arbitrary character, "$P$G.bat" contains a valid code:
If you double click on "%prompt%.bat" the code in "$P$G.bat" will be executed because %prompt% was expanded to $P$G. Although if you check the CMDCMDLINE variable you will still find the originally opened "%prompt%.bat". Arguments passed to "%prompt%.bat" are accessible in "$P$G.bat".
- "%prompt%.bat" contains at least one arbitrary character, "$P$G.bat" is empty:
If you double click on "%prompt%.bat" the "$P$G.bat" file will be executed. That means the cmd window opens and closes immediately because the end of the file was reached. The OS doesn't complain because the check for emptyness was done to "%prompt%.bat" before.
Regards
aGerman