How to add the "Pin to Start Screen" context menu item to all files in Windows 8.1 (PowerShell)
Introduction
This PowerShell script sample shows how to add the "Pin to Start Screen" context menu item to all files in Windows 8.1
Scenarios
With Windows 8.1, Microsoft has restricted access to the 'Pin to Start Screen' menu command for 3rd party apps. The same thing could be implemented in Windows 8. Any app was able to pin itself to the Start Screen, but not so in Windows 8.1. So this script can get the "Pin to Start Screen" context menu item unlocked for every file, and every file system object in Explorer.
Note
This script can help you to modify the registry automatically. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base: 322756 (How to back up and restore the registry in Windows)(http://support.microsoft.com/kb/322756/ )
Script
Step 1: Click Start, type powershell in the search box on the Start Menu, right-click the Windows PowerShell icon, and then click Run Windows PowerShell as administrator. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
Step2: Start the PowerShell Console with administrator. To run the script in the Windows PowerShell Console, type the command< Script Path> at the Windows PowerShell Console.
For example, type C:\Script\AddItemContextMenu.ps1
This is shown in the following figure.
When the script finishes running, you will see the following figure.
As you can see, the "Pin to Start" item has been added to context menu successfully.
Here are some code snippets for your reference.
#Define the registry key path
$KeyPath = "HKCU:\Software\Classes"
New-Item -Path "$KeyPath" -ItemType File -Name "*" -ErrorAction SilentlyContinue | Out-Null
New-Item -Path "$KeyPath\````*" -ItemType File -Name "shellex" -ErrorAction SilentlyContinue | Out-Null
New-Item -Path "$KeyPath\````*\shellex" -ItemType File -Name "ContextMenuHandlers" -ErrorAction SilentlyContinue | Out-Null
New-Item -Path "$KeyPath\````*\shellex" -ItemType File -Name "ContextMenuHandlers" -ErrorAction SilentlyContinue | Out-Null
New-Item -Path "$KeyPath\````*\shellex\ContextMenuHandlers" -ItemType File -Name "PintoStartScreen" -ErrorAction SilentlyContinue | Out-Null
New-Item -Path "$KeyPath\````*\shellex\ContextMenuHandlers" -ItemType File -Name "PintoStartScreen" -ErrorAction SilentlyContinue | Out-Null
Set-ItemProperty -Path "$KeyPath\````*\shellex\ContextMenuHandlers\PintoStartScreen" -Name "(Default)" -Value "{470C0EBD-5D73-4d58-9CED-E91E22E23282}"
#Define the registry key path $KeyPath = "HKCU:\Software\Classes" New-Item -Path "$KeyPath" -ItemType File -Name "*" -ErrorAction SilentlyContinue | Out-Null New-Item -Path "$KeyPath\````*" -ItemType File -Name "shellex" -ErrorAction SilentlyContinue | Out-Null New-Item -Path "$KeyPath\````*\shellex" -ItemType File -Name "ContextMenuHandlers" -ErrorAction SilentlyContinue | Out-Null New-Item -Path "$KeyPath\````*\shellex" -ItemType File -Name "ContextMenuHandlers" -ErrorAction SilentlyContinue | Out-Null New-Item -Path "$KeyPath\````*\shellex\ContextMenuHandlers" -ItemType File -Name "PintoStartScreen" -ErrorAction SilentlyContinue | Out-Null New-Item -Path "$KeyPath\````*\shellex\ContextMenuHandlers" -ItemType File -Name "PintoStartScreen" -ErrorAction SilentlyContinue | Out-Null Set-ItemProperty -Path "$KeyPath\````*\shellex\ContextMenuHandlers\PintoStartScreen" -Name "(Default)" -Value "{470C0EBD-5D73-4d58-9CED-E91E22E23282}"
Windows 8.1Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.