Jump to content

How do pin a shortcut in start menu ? (windows 10)


Recommended Posts

Hello everyone.

First, sorry for mistakes, I'm french. ^^

=====

I've tried (and I try always) to pin a shortcut (lnk) to startmenu (on Windows 10).


Look this subject (in forum FR autoit) : http://www.autoitscript.fr/forum/viewtopic.php?f=21&t=12031

The script I wrote, doesn't work, despithe the display of "Épingler à l'écran de démarrage" by a consolewrite.

This is the script :

#RequireAdmin
$path = @DesktopDir & "\vlc.lnk"
PinToTaskBand($path)


Func PinToTaskBand($path)
    $objShell = ObjCreate("shell.application")
    $objFSO = ObjCreate("Scripting.FileSystemObject")

    $strFolder = $objFSO.GetParentFolderName($path)
    $strFile = $objFSO.GetFileName($path)
    $objFolder = $objShell.Namespace($strFolder)
    $objFolderItem = $objFolder.ParseName($strFile)
    $colVerbs = $objFolderItem.Verbs


    For $itemVerb In $objFolderItem.Verbs
;~         MsgBox(0,"", $itemVerb.name)
        $var = StringReplace($itemVerb.name, "&", "")
        ConsoleWrite($var & " | ")
        If $var =  "Pin to startmenu" Or $var="Épingler à l’écran de démarrage" Then
            MsgBox(0, "", 1)
            $itemVerb.DoIt
        EndIf
    Next
EndFunc   ;==>PinToTaskBand

Func UnpinToTaskBand($path)
    $objShell = ObjCreate("shell.application")
    $objFSO = ObjCreate("Scripting.FileSystemObject")

    $strFolder = $objFSO.GetParentFolderName($path)
    $strFile = $objFSO.GetFileName($path)
    $objFolder = $objShell.Namespace($strFolder)
    $objFolderItem = $objFolder.ParseName($strFile)
    $colVerbs = $objFolderItem.Verbs

    For $itemVerb In $objFolderItem.Verbs
        ConsoleWrite($itemVerb.name & " | ")
        If StringReplace($itemVerb.name, "&", "") == "Unpin from Taskbar" Or StringReplace($itemVerb.name, "&", "") == "Détacher de la barre des tâches" Then $itemVerb.DoIt
    Next
EndFunc   ;==>UnpinToTaskBand
If StringInStr($var, "Pin to startmenu") Or StringInStr($var, "Épingler à l’écran de démarrage") Then
                MsgBox(0, "", 1)
                $itemVerb.DoIt
            EndIf

 

It shows 1 (msgbox) correctly.
But $itemVerb.DoIt doesn't work.


Someone would he know how to do ?
If i do mistakes, where are it ? Please.

Else, is there another way to pin a shortcut to startmenu (on windows 10)?

Thanks by advance.
Cheers.

Good day guys:D

Edited by littleboy62
Correction script
Link to comment
Share on other sites

You can add items to the start menu by creating a shortcut in the following directories:

Current User = %AppData%\Microsoft\Windows\Start Menu\Programs

Local Machine = C:\ProgramData\Microsoft\Windows\Start Menu\Programs 

Once they have been added, right clicking on them should give you an option to pin them to the start menu.

 

 

 

 

Link to comment
Share on other sites

  • 7 months later...
On 28/05/2016 at 11:03 PM, BetaLeaf said:

You can add items to the start menu by creating a shortcut in the following directories:

Current User = %AppData%\Microsoft\Windows\Start Menu\Programs

Local Machine = C:\ProgramData\Microsoft\Windows\Start Menu\Programs 

Once they have been added, right clicking on them should give you an option to pin them to the start menu.

 

 

Not the purpose of the request in topic.

Script = automotion

Right click manualy = no automotion

Actualy if i am not whrong:

No one even the best expert can do that, becose microsoft locked that to keep taskbar clean of malware adds

this affirmation is correct only for system architecture after W7

 

Paliative solution :

0-[Blockinput] =1

1-Open an explorer windows in witch one you got the Exe file

2-[Move] the windows to 0,0

3-[Send] the EXE name fast enouth to higthlight it

4-[Send] context menu

5-[send] {down} {down}.....[click] pin to....

6-[blockinput] = 0

 

Yeah very ugly way

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

In Windows 10 you need to use PowerShell as the verb method no longer works:
nb1: Shortcuts need to exist of course and should be in %AllUsersProfile% Start Menu
nb2: In Windows 10 1607/2016 you can also add Task Bar menu items (The XML code below is for Windows 10 1607)
nb3: This adds the shorcuts for all "New Users" only.

Start Menu/TaskBar Example File

<?xml version="1.0" encoding="utf-8"?>
<LayoutModificationTemplate
    xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification"
    xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout"
    xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout"
    xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout"
    Version="1">
<LayoutOptions StartTileGroupsColumnCount="1" />
  <DefaultLayoutOverride>
    <StartLayoutCollection>
      <defaultlayout:StartLayout GroupCellWidth="6" xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout">
        <start:Group Name="Items" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout">
          <start:DesktopApplicationTile Size="2x2" Column="2" Row="0" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Outlook 2013.lnk" />
          <start:DesktopApplicationTile Size="2x2" Column="2" Row="2" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\PowerPoint 2013.lnk" />
          <start:DesktopApplicationTile Size="2x2" Column="0" Row="2" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Excel 2013.lnk" />
          <start:DesktopApplicationTile Size="2x2" Column="4" Row="2" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Word 2013.lnk" />
          <start:DesktopApplicationTile Size="2x2" Column="4" Row="0" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Skype for Business 2015.lnk" />
          <start:DesktopApplicationTile Size="2x2" Column="2" Row="4" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Google Chrome.lnk" />
        </start:Group>
      </defaultlayout:StartLayout>
    </StartLayoutCollection>
  </DefaultLayoutOverride>
  <CustomTaskbarLayoutCollection PinListPlacement="Replace">
    <defaultlayout:TaskbarLayout>
      <taskbar:TaskbarPinList>
        <taskbar:DesktopApp DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Excel 2013.lnk" />
        <taskbar:DesktopApp DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Outlook 2013.lnk" />
        <taskbar:DesktopApp DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\PowerPoint 2013.lnk" />
        <taskbar:DesktopApp DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Word 2013.lnk" />
        <taskbar:DesktopApp DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Google Chrome.lnk" />
      </taskbar:TaskbarPinList>
    </defaultlayout:TaskbarLayout>
  </CustomTaskbarLayoutCollection>
</LayoutModificationTemplate>

Power Shell Command in Autoit

$hXML_STARTMENU = @ScriptDir & '\StartMenu.xml'
If @OSArch = 'x64' Then
    DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turns On 64 Bit Redirection
        RunWait('@ComSpec@ /c Powershell.exe -command "& {Import-StartLayout –LayoutPath $hXML_STARTMENU$ -MountPath $env:SystemDrive\}"', '@WindowsDir@\System32', @SW_HIDE)
    DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turns Off 64 Bit Redirection
Else
    RunWait('@ComSpec@ /c Powershell.exe -command "& {Import-StartLayout –LayoutPath $hXML_STARTMENU$ -MountPath $env:SystemDrive\}"', @SystemDir, @SW_HIDE)
EndIf

 

Link to comment
Share on other sites

Did you tryed on w10 architectur 😳? 

 

Wow big like

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

@Caramen - I use this as part of the build for our Windows 10 images, normally apply this after applications have been installed and build the XML file via script as we have different applications for Start Menu/Task Bar shortcuts for different systems for example Kiosk, Desktops and Laptops.  Technically you can also just rename the xml file to "LayoutModification.xml" in "C:\Users\Default\AppData\Local\Microsoft\Windows\Shell" as that's all the PowerShell command does.

Link to comment
Share on other sites

WoW man you are the first to show me a solution for that. Guess you are skilled. 

But you need an up to date system is that rigth ?

 

i am gonna test that next week i have No Time atm and feed back ofc

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...