簡體   English   中英

如何將參數作為字符串從批處理文件傳遞到另一個文件

[英]How to pass parameters from a batch file to another as strings

因此標題可能不太清楚我想要的內容,但是基本上我有以下代碼:

echo python %2 "%1" >> activate_wrapper.bat

這段代碼位於.bat文件中,目的是構建另一個將運行python腳本的.bat文件。 問題是我不想將%1的值寫入Activate_wrapper.bat,我想寫入字符串“%1”。

Activate_wrapper.bat中的預期行:

python secondArg %1

我得到什么:

python secondArg "firstArg"

在此先感謝大家。

解:

echo python %2 %%1 >> activate_wrapper.bat

電腦無法讀懂您的想法,也不知道您只想擴展其中一個參數!

您必須轉義%以防止擴展:

echo hello %2 "%%1" >> temp.txt
set something=whatever
echo hello %%something%% >> temp.txt

暫無
暫無

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

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