答案1
要通过命令行获取路径,您可以尝试:
wmic
(Windows 管理规范命令)。
wmic startup get command|find/i ProgramName|find "."
rem :: or get name.exe and command-line ::
wmic startup get caption,command|findstr /b "Program Name.exe|find "."
- 输出
steam.exe
>wmic startup get caption,command|findstr "steam.exe"|find "."
Steam "C:\Program Files (x86)\Steam\steam.exe" -silent
- 一个
for
循环建议:
for /f tokens^=1*delims^=^"^ %i in ('wmic startup get caption^,command^|findstr "steam.exe"')do @echo\%~i ^| %~j
Steam | C:\Program Files (x86)\Steam\steam.exe" -silent
- 循环输出
for
:
Steam | C:\Program Files (x86)\Steam\steam.exe" -silent
- 为了获得路径,请使用
%~dpj
for /f tokens^=1*delims^=^"^ %i in ('wmic startup get caption^,command^|find/i "steam"')do @echo\%i - %~dpj
- 循环输出
for
:
Steam - C:\Program Files (x86)\Steam\
- 基于这个问题:
使用 wmic 获取传递给可执行文件的参数