簡體   English   中英

批處理文件打開 CMD 並准備好執行 myapp.exe 文件

[英]Batch file open CMD with myapp.exe file ready to be executed

我想創建一個打開 CMD 的批處理文件將 myapp.exe 文件放在提示行(不執行)並等待用戶添加參數字符串。 我嘗試了以下方法,但是當我雙擊批處理文件時它會執行 .exe 文件。

cmd /k "C:\myapp.exe"

使用SET /P命令將關閉。 並且比填充鍵盤緩沖區要容易得多。

@ECHO OFF
SET /P PARAMS="Enter the parameter(s) with which to run C:\myapp.exe: "
REM If nothing is entered, do not run the program.
IF NOT "%PARAMS%" == "" ("C:\myapp.exe" %PARAMS%)
EXIT /B

也許這就是您想要的, (只需根據需要更改第2行的可執行字符串)

@Echo Off & SetLocal EnableExtensions
Set "Executable=C:\myapp.exe"
%SystemRoot%\System32\cmd.exe /D /K "Set "args=" & Set /P "=%Executable% " 0< NUL & Set /P "args=" & For /F Tokens^=*^ EOL^= %%G In ('Call Set /P "=%%args%%" 0^< NUL') Do @If "%%G" == "%%args%%" ("%Executable%") Else "%Executable%" %%G"

我喜歡浪費茶歇:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM