LoginSignup
0
0

ノートPCのバッテリーレベルをTeamsに投稿するバッチ

Posted at

monitor_start.batをタスクスケジューラに登録

monitor_start.bat
@echo off
echo Bttery Check

rem Incoming WebhookのURLを格納
set URL="★Teamsのwebhook URL"

set POSTTEXT=Battery Post

cscript.exe /Nologo monitor_battery.vbs

echo %ERRORLEVEL%

curl.exe -H "Content-Type:application/json" -d "{'text':'%POSTTEXT% %ERRORLEVEL% Percent'}" %URL%

monitor_battery.vbs
'---------------------------------------------------
' ノートPCのバッテリ算容量を取得する
' usage: cscript /Nologo バッテリ容量.vbs
'---------------------------------------------------
Set rows = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from Win32_Battery",,48)
 
For Each row in rows
    Wscript.Echo row.EstimatedChargeRemaining
    Wscript.Quit(row.EstimatedChargeRemaining)
Next

参考リンク

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