How to Add "Restart", "Shutdown" , "Sleep" and "Lock" to the Desktop Context Menu in Windows 8 (VBScript)

Introduction

The goal of this script is adding "restart", "shutdown", "sleep" and "lock" to the desktop context menu in Windows 8.

Scenarios

It will be more convenient if there are "restart", "shutdown", "sleep" and "lock" in context menu.

Script

Step 1: Press Win key and "X", and select "Command Prompt (Admin)"

Step 2: Type command like the following:
Cscript.exe filepath add (remove)

After script executed:

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

VB Script
Edit|Remove
If KeyExists("HKEY_CLASSES_ROOT\DesktopBackground\Shell\lock Computer\") = False   Then  
    CreateKeys "Lock Computer","shell32.dll,-325","Rundll32 User32.dll,LockWorkStation" 
End If  
'add 'restart computer'  
If KeyExists("HKEY_CLASSES_ROOT\DesktopBackground\Shell\Restart Computer\") = False   Then  
    CreateKeys "Restart Computer","shell32.dll,-221","shutdown.exe -r -t 00 -f" 
End If 
'add 'sleep computer' 
If KeyExists("HKEY_CLASSES_ROOT\DesktopBackground\Shell\Sleep Computer\") = False   Then  
    CreateKeys "Sleep Computer","shell32.dll,-331","rundll32.exe powrprof.dll,SetSuspendState 0,1,0"   
End If 
'add 'shutdown computer' 
If KeyExists("HKEY_CLASSES_ROOT\DesktopBackground\Shell\Shutdown Computer\") = False   Then  
    CreateKeys "Shutdown Computer","shell32.dll,-329","shutdown.exe -s -t 00 -f"  
End If         
WScript.Echo "Add 'Lock,Restart,Sleep,ShutDown Computer' to context menu successully"

Prerequisite

Windows 8