net use command works in command prompt, but not in bat file
Solution 1:
The percent sign (
%
) is a special case. On the command line, it does not need quoting or escaping unless two of them are used to indicate a variable, such as%OS%
. But in a batch file, you have to use a double percent sign (%%
) to yield a single percent sign (%
). Enclosing the percent sign in quotation marks or preceding it with caret does not work.[…]
echo The ratio was 47%
- If run from a batch, the percent sign is ignored.
echo The ratio was 47%%
- If run from a batch, the percent sign is output once.
(source)