Thursday, December 19, 2013

Pin a program to start menu

To add a new pinned item to Start Menu in windows 7 using scripts or in an automated way, we need to do 3 things.
1.       Pin the shortcut icon manually
2.       Export and import the shortcut
3.       Export and import registry key

First we manually configure the desired settings then export the shortcuts and the registry settings. Then we will use script to copy the shortcuts and import the registry values to all other machines.

In this example I use Firefox browser to pin to start menu. So select Firefox browser, Right click on the Firefox browser shortcut then click on Pin to Start Menu.
Now the shortcut is pinned to the start menu. When we choose Pin to Start Menu, the system will copy the shortcut to the below location; “C:\Users\%Username%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\” folder.
The new pinned item also updates the Startpage2 registry key under Current User.
Go to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage2
Right click on the StartPage2 key then export the registry key. Once the registry key is exported replace HKEY_CURRENT_USER with HKEY_USERS\Default This is how the NTUSER.DAT will be mounted to the hive (as below)

Now, we need to use a simple batch file to copy the shortcut to default user and export the current user key to default user as well. This will create the Pinned items to all users.
The script will look like this;
echo Pin Firefox shortcut to Start menu

REM First copy the shortcut to all users (Defualt)
Xcopy "%~dp0Firefox.lnk" "C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\"

REM Apply the current user registry key to all users (NTUSER.DAT)
REG IMPORT "%~dp0Startpage2.reg"

Add the Shortcut, batch file and Startpage2.reg to a package then use with SCCM task sequence or any other deployment tool to deploy these settings through the OS deployment.

No comments:

Post a Comment