use*_*666 6 windows 64-bit batch-file windows-command-prompt
我有一个可以正常工作的现有 CMD 脚本。它从程序文件中启动一个应用程序,就像这样
"%PROGRAMFILES%\MyApp\app.exe"
Run Code Online (Sandbox Code Playgroud)
这是我能想到的最好的:
set strProgramFiles=%ProgramFiles%
if exist "%ProgramFiles(x86)%" set strProgramFiles=%ProgramFiles(x86)%
"%strProgramFiles%\MyApp\app.exe"
Run Code Online (Sandbox Code Playgroud)
类似于马特的正确答案。基本上在这个版本中,完整的路径被验证。
SET AppExePath="%ProgramFiles(x86)%\MyApp\app.exe"
IF NOT EXIST %AppExePath% SET AppExePath="%ProgramFiles%\MyApp\app.exe"
%AppExePath%
Run Code Online (Sandbox Code Playgroud)