Wednesday, April 3, 2013

How to create a Shutdown/Restart/Logoff Windows 8 Tile for the Start menu (PowerShell)

Script to create a Shutdown / Restart / Logoff Windows 8 Tile for the Start menu ( PowerShell )

Introduction

This PowerShell script shows how to create a Shutdown, Restart or Logoff Windows 8 tile for the Start menu.


Demo


Get Microsoft Silverlight
-->

Scenarios

In Windows 8, without a Start button, properly shutting down or rebooting Windows can be a bit of a chore. Many users want to shut down or reboot Windows in just one click. This script enables users to click on a tile to shut down, reboot or log off Windows on the Start menu.

Script

Step1: Run the script in the Windows PowerShell Console, type the one command: Import-Module <Script Path> at the prompt.
For example, type Import-Module C:\Script\ CreateWindowsTile.psm1This is shown in the following figure.
Step 2: You can type the command Get-Help New-OSCWindowsTile -Full to display the entire help file for this function, such as the syntax, parameters, or examples.

-->


Example

Example 01: Type New-OSCWindowsTile command in the Windows PowerShell Console.
This command will create a shutdown, restart and logoff Windows 8 tile to the Start menu.
As you can see, in the following figure, the shutdown, restart and logoff Windows 8 tile has been created successfully.
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. 
PowerShell
#create a new shortcut of shutdown 
$ShutdownShortcutPath = "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\Shutdown.lnk" 
$ShutdownShortcut = $WshShell.CreateShortcut($ShutdownShortcutPath$ShutdownShortcut.TargetPath = "$env:SystemRoot\System32\shutdown.exe" 
$ShutdownShortcut.Arguments = "-s –t 0" 
$ShutdownShortcut.Save() 
  
#change the default icon of shutdown shortcut 
$ShutdownLnk = $Desktop.ParseName($ShutdownShortcutPath$ShutdownLnkPath = $ShutdownLnk.GetLink 
$ShutdownLnkPath.SetIconLocation("$env:SystemRoot\System32\SHELL32.dll",27) 
$ShutdownLnkPath.Save() 

Download Script

To download the full script please click here: Download Script
-->

No comments:

Post a Comment