批處理只執行第一句,其他的不被執行,怎么辦?


我寫了一個批處理來配置Windows的PowerShell Remote,腳本如下:

winrm quickconfig -quiet
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}
winrm set winrm/config/client/auth @{Basic="true"}
winrm set winrm/config/client @{AllowUnencrypted="true"}
winrm get winrm/config

 

存成WinrmSetup.bat, 之后用administrator開啟一個CMD,結果就只執行第一句,后面的命令就好像沒寫一樣。

額,汗。

 

網上查了一下,照着改,測試成功,原來每條命令前面都加個call就可以了。

call winrm quickconfig -quiet
call winrm set winrm/config/service/auth @{Basic="true"}
call winrm set winrm/config/service @{AllowUnencrypted="true"}
call winrm set winrm/config/client/auth @{Basic="true"}
call winrm set winrm/config/client @{AllowUnencrypted="true"}
call winrm get winrm/config

 

無力吐槽這個問題了.

 

參考資料

==========

Why does only the first line of this Windows batch file execute but all three lines execute in a command shell?

http://stackoverflow.com/questions/4036754/why-does-only-the-first-line-of-this-windows-batch-file-execute-but-all-three-li


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM