簡體   English   中英

通過Powershell在批處理文件中傳遞參數

[英]Pass parameters in batch file from powershell

我已經在Windows中制作了一個批處理文件。 該文件中的內容是這樣的

測試棒

echo %1

現在,當我從命令行發送這樣的參數時

test.bat "hello"

那么它總是輸出%1 應該hello

我做錯了什么?

這確實很奇怪-您對文件中內容的假設不正確。 這是我電腦的輸出,完全按照您的描述進行:

C:\windows\system32>copy con test.bat
echo %1
^Z
        1 file(s) copied.

C:\windows\system32>test.bat hello

C:\windows\system32>echo hello
hello

我懷疑該文件與您描述的內容有所不同

也許您正在使用Power-shell。 您需要在bat文件中使用以下命令:

echo $1

這是將DOS批處理文件轉換為Shell腳本

 http://tldp.org/LDP/abs/html/dosbatch.html

暫無
暫無

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

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