Battery Alarm VBS Script

Simple VBS script (save it as .vbs file and run) to get once the laptop battery is charged up to given (90 in this case) percentage.

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 > 90) Then msgbox "Battery is at " & iPercent & "%",vbInformation, "Battery monitor"
 wscript.sleep 30000 ' 5 minutes
wend

Restore Windows Booloader using command line at boot time

If due to any reason you lost your boot system, you can restore window’s bootloader using windows CD or bootable pendrive. You may need this to do if you had linux grub earlier which you uninstalled now, or due to damage to bootloader.

Follow these steps to restore MBR (Master Boot Loader) for Windows Bootloader

  1. First of all insert Windows CD / bootable pendrive in your computer and start it. (follow my another post if you need to know how to make your pendrive bootable manually)
  2. Now go to Command line at boot time
    • In windows 7, select ‘Repair your computer’ >’Startup Recovery Option’ > ‘Command Line’
    • In windows 8, select ‘Repair your computer’ > ‘Troubleshoot’ > ‘Advance Options’ > ‘Command Line’
  3. Now give following commands
      • bootrec /fixmbr
      • bootrec /fixboot
      • bootrec /scanos

Problem in enabling .NET Framework on Windows 8

Another post of mine describes why we need to enable .NET framework 3.5 manually on windows 8, and all methods to enable it. Now I will tell you what if you are unable to enable it. I am going to take only very specific case, may not be applicable everywhere.

I tried to enable it using DISM command (I had my windows8 ISO image mounted on I: drive)

DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:I:\sources\sxs

But it didn’t work, In such case I tried a lot of other options but could not find any solution. Finally I tried removing /All and /LimitAccess in above command and I worked 🙂 So you can also try just the following command

DISM /Online /Enable-Feature /FeatureName:NetFx3 /Source:I:\sources\sxs

Enabling .NET Framework on Windows 8

The .NET Framework 4.5 is included with Windows 8 and installed on your computer with the Windows 8 operating system. But the .NET Framework 3.5 is not automatically installed with Windows 8. So whenever you will try to install any software / app on you computer which uses this framework will ask to first install such .NET framework 3.5.

So to run apps that require the .NET Framework 3.5 on Windows 8, you must enable version 3.5 on your computer. There are two ways you can do this: by installing or running an app that requires the .NET Framework 3.5 (that is, by installing the .NET Framework 3.5 on demand), or by enabling the .NET Framework 3.5 in Control Panel. Both options require an Internet connection. You can use DISM (Deployment Image Servicing and Management) to enable it directly from ISO image file or DVD.

Now either your software(which requires .NET framework ) setup will automatically install the framework on Demand using internet, or you can manually install it from control panel. In Control Panel, choose Programs and Features, choose Turn Windows features on or off, and then select the .NET Framework 3.5 (includes .NET 2.0 and 3.0) check box. This option requires an Internet connection. You do not need to select the child items for Windows Communication Foundation (WCF) HTTP activation unless you are a developer who requires WCF script and handler mapping functionality.

If you cannot connect to the Internet, you can enable the .NET Framework 3.5 by using the Deployment Image Servicing and Management (DISM) command-line tool and specifying the installation media (ISO image or DVD) you installed Windows 8 from.

  1. In Windows 8 or Windows Server 2012, open a Command Prompt window with administrative credentials (that is, choose Run as administrator).
  2. To install the .NET Framework 3.5 from installation media located in the D:\sources\sxs directory, use the following command:DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:d:\sources\sxswhere:
    • /Online targets the operating system you’re running (instead of an offline Windows image).
    • /Enable-Feature /FeatureName:NetFx3 specifies that you want to enable the .NET Framework 3.5.
    • /All enables all parent features of the .NET Framework 3.5.
    • /LimitAccess prevents DISM from contacting Windows Update.
    • /Source specifies the location of the files needed to restore the feature (in this example, the D:\sources\sxs directory).

    For more information about DISM parameters and options, see How to Enable or Disable Windows Features

IF THIS DOESN’T WORK THEN YOU CAN REMOVE /All and /LimitAccess from above command, it may work fine 🙂