Results 1 to 4 of 4
  1. #1
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,970
    Thanks
    424
    Thanked 1,600 Times in 1,450 Posts

    Strange Context Menu Behavior

    Hey Y'all,

    I thought I was going crazy, well crazier than I already am!

    When calling a PS program from the SendTo menu in File Explorer:
    CMF SendToMenu.JPG

    Windows passes an array of the select files for the program to process.

    Shortcut Command used:
    Code:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "G:\BEKDocs\Scripts\Production\Copy-MultiMachines.ps1"
    CMF Using SendTo Shortcut.JPG

    Which is what I expected to happen if I moved the process up one menu level:
    CMF Context Menu.JPG

    Note: if you delete the "%1" the program will tell you that no files were passed!.

    Does anyone know the reason for this inconsistency? I'm sure it is designed that way but for the life of me I can't understand why.

    HTH

    However, now Windows calls the program once for each file selected vs passing an array.

    Pressing the Exit button will redisplay the machine selection menu then process the next file in the group.

    The registry entry used:
    RunAsCMRegEntry.JPG
    CMF Using Context Menu.JPG
    Last edited by RetiredGeek; 2017-02-09 at 23:02.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  2. #2
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    24,335
    Thanks
    5
    Thanked 1,204 Times in 1,051 Posts
    Even though this thread is about C#, see the post marked as an answer - Implement Explorer ContextMenu and pass multiple files to one program instance.
    Joe

  3. The Following User Says Thank You to JoeP517 For This Useful Post:

    RetiredGeek (2017-02-10)

  4. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,970
    Thanks
    424
    Thanked 1,600 Times in 1,450 Posts
    Joe,

    Thanks for the reference. However, I think this solution is a bit above my pay grade! I think I'll just keep it on the SendTo menu for simplicity.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #4
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    24,335
    Thanks
    5
    Thanked 1,204 Times in 1,051 Posts
    Didn't think you'd want to build a ShellExtension but at least you have an explanation.
    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •