littleboy62

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

7 posts in this topic

#1 ·  Posted (edited)

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

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

#3 ·  Posted (edited)

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

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

 

1 person likes this

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Did you tryed on w10 architectur 😳? 

 

Wow big like

Edited by caramen

Share this post


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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

    • TheWizEd
      By TheWizEd
      How do I work with 2D arrays.  I've tried this but get errors.
      Local $aTest[4][4] = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
      ;$aTest[0][] = [10,11,12]  ; Error at []
      Local $sTest = ""
      For $i = 0 To UBound($aTest)-1
        Local $aExtract = _ArrayExtract($aTest,$i,$i)
        $sTest = $sTest & MyTest($aExtract)
      Next
      Func MyTest($aTemp)
        _ArrayDisplay($aTemp)
        ; Error at    v $aTemp
        Return String($aTemp[0]) & " - " & String($aTemp[1]) & " - " & String($aTemp[2]) & @CRLF
      EndFunc
       
       
    • AndyK70
      By AndyK70
      I'm trying to fill a ListView with all normal viewable windows to act with them.
      First I tried with WinList:
      Local $aWinList = WinList("[REGEXPTITLE:(?i)(.+)]") Local $aTmp, $iID ;~ _ArrayDisplay($aWinList) For $i = $aWinList[0][0] To 1 Step -1 ; going backwards not disturbing the index while cycling through and deleting some If StringStripWS( $aWinList[$i][0], 3) == "" Or _ Not BitAND(WinGetState($aWinList[$i][1]), $WIN_STATE_VISIBLE) Or _ BitAND(WinGetState($aWinList[$i][1]), $WIN_STATE_MINIMIZED ) Then _ArrayDelete($aWinList, $i) Else ; Window has a Title and is "visible" $aTmp = WinGetPos($aWinList[$i][1]) If $aTmp[0] < -1000 Or $aTmp[1] < -1000 Then ; Window is minimized or tray icon _ArrayDelete($aWinList, $i) EndIf EndIf Next $aWinList[0][0] = UBound($aWinList)-1 ; getting actual # of windows ; Each row is now [ID]=> [Title], [hWnd] But it keeps getting Windows which are definitely not there at least not visible:

      Those windows "Rechner", "Einstellungen", "Netflix", "Microsoft Store", ... are not there!?! 
      It should list only the first three windows, which are real.
      I even tried it with _WinAPI_ UDF:
      $hWnd = _WinAPI_GetForegroundWindow() ; Add items _GUICtrlListView_BeginUpdate($idListview) If $hWnd <> 0 Then $iI = 0 Do If _WinAPI_IsWindow($hWnd) And _WinAPI_IsWindowVisible Then _GUICtrlListView_AddItem($idListview, WinGetTitle($hWnd)) _GUICtrlListView_AddSubItem($idListview, $iI, $hWnd, 1) $iI += 1 $hWnd = _WinAPI_GetWindow($hWnd, $GW_HWNDNEXT) EndIf Until $hWnd = 0 EndIf But it is the same...
       
      How can i distinguish those invisible windows from normal ones?
      PS: I'm using Windows 10, maybe it is important to know?
    • davidacrozier
      By davidacrozier
      Hello all ~
      I am running an autoit script on Windows 10 inside VMware Workstation 12 Pro version 12.5.2.  Technically I am remoting into ESXi which has a Domain Controller (DC), WebServer, FilServer, Windows 10, etc.  Using the GUI (i.e. running explorer.exe) I am able to open several different folders successfully.  The desktop, documents, USB external all open without issue.  The network share opening gives me issues.  Whenever I attempt to open \\filserver\users\user\sharedfolder I get the documents folder instead.  I understand that the documents folder is the default for explorer.  I have also attempted to use the letter drive mapped to the network share (Z:) and receive the same result.  When I run this script on Windows 10 alone without  the VM or the ESXi I am able to open the network share without problems.  I have tried to use the net use command to designate a letter M: to the network share folder prior to running the script.  This did not work for me.  
      One additional avenue I think might work is to use the systreeview321 and _GUICtrlTreeView_FindItem to step through the tree looking for the network share.  Once found,  double click on it and see if that opens the shared network folder.  I can click inside the VM with my mouse on the network share and it opens just fine.  Not sure if running up against GUI issues, or permission issues, or what?
      Thanks in advance,
      Davida Crozier
      TestNetworkShare.au3
      This script is a subset of a much larger program, but it illustrates what I am dealing with.

    • MrMajorThorburn
      By MrMajorThorburn
      Using sample code:
      #include <MsgBoxConstants.au3> ; Find a pure red pixel in the range 0,0-20,300
      Local $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000)
      If Not @error Then
          MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
      Else
          MsgBox($MB_SYSTEMMODAL, "", "Pure Not Found")
      EndIf ; Find a pure red pixel or a red pixel within 10 shades variations of pure red
      $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
      If Not @error Then
          MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
      Else
          MsgBox($MB_SYSTEMMODAL, "", "Variant Not Found")
      EndIf   and the attached screenshot which has Pure Red (FF0000) in one icon in the area being searched. Would someone please check this out for me?
    • BBs19
      By BBs19
      Features:
      Create modern looking borderless and resizable GUIs with control buttons (Close,Maximize/Restore,Minimize, Fullscreen, Menu) True borderless, resizeable GUI with full support for aerosnap etc. Many color schemes/themes included. See MetroThemes.au3 for more details. 3 type of Windows 8/10 style buttons. Modern checkboxes, radios, toggles and progressbar. All buttons, checkboxes etc. have hover effects! Windows 10 style modern MsgBox. Windows 10/Android style menu that slides in from left. Windows 10 style right click menu  
      Credits: @UEZ, for the function to create buttons with text using GDIPlus. @binhnx for his SSCtrlHover UDF
       
      Changelog:
      Download UDF with example: