Jump to content
littleboy62

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

Recommended Posts

littleboy62

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

Share this post


Link to post
Share on other sites
BetaLeaf

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.

 

 


False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites
caramen
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

Share this post


Link to post
Share on other sites
Subz

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

 

  • Like 2

Share this post


Link to post
Share on other sites
caramen

Did you tryed on w10 architectur 😳? 

 

Wow big like

Edited by caramen

Share this post


Link to post
Share on other sites
Subz

@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.

Share this post


Link to post
Share on other sites
caramen

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

Share this post


Link to post
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

  • Similar Content

    • Daydreamer067
      By Daydreamer067
      Hi
      in windows 10 i create a new desktop.
      I want to run a script in this desktop, for exemple Mouseclick("left",x,y)
      I want the script to work in that desktop while i switch to the primary desktop.
      So far autoit clicks on the active desktop.
      Is there a way to make it run only on the other desktop ?
       
      Thank you for your response.
    • codingislife
      By codingislife
      Hi everyone, 
      I'm new to the autoit world and am trying to do something a little complicated and am having trouble developing a solution. My OS after reimaging comes up with two operating system choices during boot up, I'd like to delete the incorrect OS. I have noticed that the default OS is always the correct OS. My issue is I need a way to find the OS identifier before I can delete. I know that I  can use bcdedit to find this but it changes every time and it needs to be the correct identifier (i.e. not the Default or bootmgr). If someone knows of a way to parse through the output of bcdedit to find the identifier that would be greatly appreciated. Here is an example of what I am trying to do:
      https://scottiestech.info/2016/07/03/remove-the-choose-an-operating-system-message-when-starting-your-computer/
    • PramodR
      By PramodR
      Hello,
      i am new to AUTO IT development , I would like one help to read value from a POP up.
      i am able to read below values using inspect tool , information given below, I tried to create a script to read value but that does not help. any help is appreciated.
      Available Controls
      POPUP window Controls
      Auto Id = "UpdateNow_Btn"
      Name = Update Now
      Invoke - Button Control
      Below Controls i get when i move inspector tool to the text which i need to read. i need to read the text Name . Currently with my code i get only blank text 
      Auto Id = timeOutLb
      ClassName = TextBlock
      LegacyIAccess = GetName
      Name  = Read Value for Name
       
      My code.
       
    • Dreamfire
      By Dreamfire
      Hi,
      Since today, exe's are being flagged as having a trojan by Windows Defender (Fuery.B!cl)
      Version:  3.3.14.3 - SciTE Version 3.7.3



       

    • PramodR
      By PramodR
      Hello,
      I have to execute below block of code in elevated previllage, as that particular wmic class will work only with admin previlage.
      i am getting out put when i launch autoit as administrator,  but i will not be able to launch autoit as admin in this particular case but my user have admin rights.
      is there any better way i can run those command as administrator.?
      tried below steps:
      i have tried #RequireAdmin but that creates a user prompt  Tried using Runas command but gives error as wrong username or password , stuck with that step.  
       
×