for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=a"') do ( set usemenu=a ) for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=b"') do ( set usemenu=b ) for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=c"') do ( set usemenu=c ) 对,%20in%20this%20code%20(which%20may%20not%20work,%20that%20what%20i%27m%20trying%20to%20find%20out)%20we%20have%20this%20%22%%a%
首先,%20%20%20变量%%20和%20%%a之间的%20差异%20是什么?
其次,有人可以向我解释"for"命令吗?
什么%20I%20am%20trying%20to%20do%20is%20pull%20a%20variable%20from%20options.txt,%20so%20i%20can%20change%20the%20menu%20style%20of%20my%20game%20launcher.%
感谢您提前提供任何帮助!
答案 %variable%是环境 变量。set并可以通过以下方式访问%foo%或者!foo!(如果启用,则延迟扩展)。%%a是由创建的特殊变量for命令来表示当前循环项或当前行的标记。
for可能是批处理文件中最复杂和最强大的部分。for有你涵盖的吗?help for有一个总结。
你可以
迭代文件:for %x in (*.txt) do ... 重复某事n 次数:for /l %x in (1, 1, 15) do....