Wednesday, 23 September 2020

No screensaver script

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Do While True
WshShell.SendKeys("{SCROLLLOCK}")
WScript.Sleep(174000)
Loop


Save above content with vbs extension in Notepad.

Paste this file in startup folder, so that it automatically runs whenever you start your system.

Goto run (Windows Key + R ), type shell:startup




This script, press Scroll Lock every 2.9 minutes (17400 milliseconds), so that screensaver doesn't appear. 



Sunday, 16 August 2020

VBScript to find out if Laptop Battery has charged

set oLocator = CreateObject("WbemScripting.SWbemLocator")
set oServices = oLocator.ConnectServer(".","root\wmi")
set oResults = oServices.ExecQuery("select * from batteryfullchargedcapacity")
for each oResult in oResults
   iFull = oResult.FullChargedCapacity
next
while (1)
  set oResults = oServices.ExecQuery("select * from batterystatus")
  for each oResult in oResults
    iRemaining = oResult.RemainingCapacity
    bCharging = oResult.Charging
  next
  iPercent = ((iRemaining / iFull) * 100) mod 100
  if bCharging and (iPercent > 79) Then msgbox "Unplug charger."
  wscript.sleep 30000 ' 5 minutes
wend