2017-02-09 39 views
-1

我正在爲Windows中的計劃關閉創建一個bat文件。這很容易,並關機-s -t 00完成工作(00秒和可更改)。用戶通過bat文件在命令提示符下輸入的值

我試圖通過命令提示符,並且再次很容易,因爲相同的命令有效地工作。

但我試圖當命令提示符顯示「關閉-s -t 00」用戶可以編輯面向對象。並且在用戶輸入新值以替換00後,整個命令(shutdown -s -t 00)可能會起作用。請幫助我。在此先感謝...

回答

1
:: Prompt the user, and store their input in variable T_VAL 
set /P T_VAL="How long to shutdown?" 

:: Call the shutdown command, putting the user-input in place of %T_VAL% 
shutdown -s -t %T_VAL% 

如果用戶輸入05,那麼命令應該是: shutdown -s -t 05

警告:
沒有安全/你的安全。

如果用戶輸入foo & format C: 然後將得到的命令是:

shutdown -s -t foo & format C: 

曹景偉:

Error: foo is not a valid value for shutdown. 
Ok: Reformatting your drive, all data will be lost. 

你有多少信任你的用戶?

相關問題