Pinning shortcuts to the Start Menu can enhance accessibility and user experience. This guide will show you how to automate the process using a script, making it easy to pin applications to the Start Menu in Windows.

Example Script to Pin a Shortcut to the Start Menu

The following script demonstrates how to pin a shortcut to the Start Menu. This script uses VBScript to automate the pinning process:

Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")

Dim Destination
Destination = Shell.ExpandEnvironmentStrings(("%APPDATA%") & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\Mozilla Firefox.lnk")
If FSO.FileExists(Destination) = True Then
    FSO.DeleteFile Destination
Else
    On Error Resume Next
End If

Set objShell = CreateObject("Shell.Application")
Set objAllUsersProgramsFolder = objShell.NameSpace("C:\ProgramData\Microsoft\Windows\Start Menu")
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
Set objFolderItem = objFolder.ParseName("Mozilla Firefox.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
    If InStr(UCase(objVerb.Name), "MENU") <> 0 And InStr(UCase(objVerb.Name), "MARRER") <> 0 Then
        objVerb.DoIt
    End If
Next

Explanation of the Script

  • Setting Constants: The constants CSIDL_COMMON_PROGRAMS and CSIDL_PROGRAMS are defined for use in the script.
  • Creating Objects: FileSystemObject and WScript.Shell objects are created for file operations and environment variable expansion.
  • Determining Destination: The destination path for the pinned shortcut is set using environment variables.
  • Deleting Existing Shortcut: If the shortcut already exists, it is deleted.
  • Accessing Start Menu: Shell.Application object is used to access the Start Menu directory.
  • Finding Shortcut: The script navigates to the Start Menu directory and finds the specified shortcut (Mozilla Firefox in this example).
  • Pinning the Shortcut: The script iterates through the verbs associated with the shortcut and executes the “Pin to Start Menu” action.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.