在 Windows 命令行中,如何正确转义这样的文件路径?文件名中包含空格、百分比和变量(例如 %cd% 和 %errorlevel%),但不扩展变量?这可能吗?
例如,运行C:\Users\the impossible %cd% filepath.exe
我已经尝试过各种方法来实现百分号转义和引号转义。文件名中没有变量时,这种方法是可行的。但是,如果文件名中包含带有变量的百分号(例如 %cd% 或 %errorlevel%),则无论使用何种转义序列,这种方法似乎都行不通。
我尝试过的事情:
"C:\Users\the impossible %cd% filepath.exe"
"C:\Users\the impossible %%cd%% filepath.exe"
"C:\Users\the impossible ^%cd^% filepath.exe"