0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VBS 指定時間経過後にシャットダウンする

Posted at

###目的
知人から、子供がyoutube見すぎるので
時間指定して強制シャットダウンしてほしいとのことで作成した。

環境:Windows10
仕様:vbsファイル起動で時間を分で指定してyoutube開く。時間強化でシャットダウンする

###スクリプト内容

'実行時間を受け取り、指定時間経過時にシャットダウンする

Option Explicit
'変数設定
Dim wsh, Response, mm

'確認メッセージを出す
Response = MsgBox("シャットダウンを予約してよろしいですか?", vbYesNo)

'Yesなら実行
If Response = vbYes Then

	'シャットダウン時間を入力。数値のみチェックする
	Do
		mm = inputbox ("シャットダウン時間を分で入力して下さい")
	Loop Until IsNumeric(mm)

	'Youtube開く
	CreateObject("Shell.Application").ShellExecute "microsoft-edge:https://www.youtube.com/"

	Set wsh = CreateObject("WScript.Shell")
	'シャットダウン	
	wsh.Run "%WINDIR%\system32\shutdown.exe -s -t " & mm * 60, 0
End If
0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?