2014-09-24 186 views
0

因此,我試圖讓用戶設置密碼,並將該密碼加載到文本文件中以便以後使用。問題在於,不是輸入用戶在文本文件中輸入的變量,而是輸入'ECHO is off'(或ECHO打開,如果打開)。使用批處理文件將一個變量輸入到文本文件中

這是我寫的。

cls 
set/p pass = Please enter your password: 
> "p.txt" (@echo %pass%) 
echo Password created! 

在此先感謝!

編輯:感謝MC ND,我有解決方案! set /p "pass= Please enter your password:"

+0

提示:突出顯示代碼並點擊ctrl-K或單擊「{}」按鈕將其變成代碼塊。手動解決方法:用4個空格縮進每行。 – 2014-09-24 17:00:06

+0

Marc B - 是的,當我更新它的時候就想通了。謝謝。 – Anonymous 2014-09-24 17:03:03

+0

您不需要用答案更新您的問題,因爲接受的答案清晰可見。 – 2014-09-24 17:52:49

回答

1

空間

set/p pass = Please enter your password: 
     ^This space is included in the name of the variable 

所以,你的變量命名爲%pass %。更改爲

set /p "pass= Please enter your password:" 
+0

謝謝,這工作完美!我會更新這篇文章。 – Anonymous 2014-09-24 17:46:21

+0

最常見的錯誤之一。我喜歡你的脫口指針風格.. – npocmaka 2014-09-24 18:15:32

相關問題