Tuesday 6 March 2018

windows - How to use `%` in a batch file


I want to associate a extension to a program by a batch file.


This command works fine when I write it interactively.


ftype wavfile="%ProgramFiles(x86)%\VideoLAN\VLC\vlc.exe" "%1"

But when I write it in a batch file and run, then %1 are recognized as a variable, so it ends up with:


ftype wavfile="%ProgramFiles(x86)%\VideoLAN\VLC\vlc.exe" ""

I think someone already ask a same question, but I couldn't find it. How can I use %1 or some other argument variables in a batch file?



Answer



You should use two percentage symbols like this: %%1, which will work for a batch file.


It will escape the %% into a percent sign.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...