これが実行可能かどうかはわかりませんが、次のバッチ スクリプトを 1 行で記述しようとしています。
@echo off
echo Shutdown initiated...
echo.
choice /c xy /n /t 10 /d y /m "To cancel shutdown press "X""
if errorlevel 2 goto EXEC
if errorlevel 1 goto ABORT
:EXEC
echo.
echo Computer shutting down
timeout /t 10
exit
:ABORT
echo.
echo Shutdown cancelled
timeout /t 10
exit
上記のスクリプトは、vbs run コマンドを介して cmd に渡す必要があります。以下は私が得ることができる最も近いものです:
option explicit
dim wshell, strcmd
set wshell = createobject("wscript.shell")
if hour(now()) >= 0 and hour(now()) < 6 then
strcmd = "cmd /c @echo off & echo ""Pre-Dawn Shutdown initiated"" & echo. & choice /c xy /n /t 10 /d y /m ""To cancel shutdown press ""X"""" & if errorlevel 2 goto exec & if errorlevel 1 goto abort & :exec & echo. & echo ""Computer shutting down"" & timeout /t 10 & exit & :abort & echo. & echo ""Shutdown cancelled"" & timeout /t 10 & exit"
wshell.run strcmd
end if
上記は、選択コマンドに到達するまで期待どおりに機能し、スクリプトは残りを正しく実行できません。これを解決するための助けをいただければ幸いです。