LoginSignup
0

More than 3 years have passed since last update.

簡易シャットダウンタイマー(バッチファイル)

Last updated at Posted at 2019-07-01

機能

  1. シャットダウンまでの時間を分単位で入力し、指定時間後、
    シャットダウンする。

  2. 「a」が入力された時は、シャットダウンタイマーを停止する。


shutdown.bat
@echo off

rem 文字入力
set /p input="shutdown(Minute or a) -> "
set temp=%input%

rem aが来たら、シャットダウンタイマー停止
if %input%==a (
    shutdown -a
    echo シャットダウンを中止
    pause
    exit
)

rem 数値列以外を弾く
echo %input%|findstr /r "^[0-9]*$" > nul
if errorlevel 1 (
    echo 無効な文字列が入力されました。
    pause
    exit
)

set min=60
rem 60をかけて、分単位に変更
set /a input=input*min
set command=shutdown.exe -s -t %input%
echo %temp%分後、シャットダウンされます。
%command%
pause
exit

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0