0

I searched over internet, but did not find suitable answers or those answers was to old for my issue.

In company where I work is more than 10 PC with different windows OS (windows 7, windows vista, windows 10). On these machines I need to set up my application, which copies and renames one excel file from any location to one predefined. After that runs another (not my) application. For better workflow, I want run that app only from windows context menu when user makes right click on file which will be copied. To make some restrictions in the process, I want make restriction to context menu item appearance on right click.

E.g. In some folder located file "****tags****.xlsx". When this file is right clicked, in context menu is visible command "Copy&Print With...". If file mask does not match, then context menu item not visible.

My main problem: context menu item creation and control of that context menu item visibility. I think is possible to do by registry changes, but I don’t know how to make file mask restriction. And of course, different versions of windows make some difficulties.

I will be very pleased for any suitable answers.

AlexK
  • 11
  • 3
  • I don't know where you looked but there are a lot of answers. See https://stackoverflow.com/a/48658377/832052 – djv Aug 20 '19 at 15:44
  • I need not file extension. Such samples everywhere. i need for file mask. – AlexK Aug 20 '19 at 16:45
  • I don't think that's possible via the regular methods. Perhaps if you make a shell extension, but that requires C/C++ and quite some knowledge about how shell extensions work. – Visual Vincent Aug 20 '19 at 18:36

1 Answers1

1

After more than one day of trying different solutions, I got result which works as I expected. Now I realise day spend for such solution is to much. Maybe it helps someone spend less time.

I don't know yet other how it will be on other windows OS, but this registry change for windows 10 works:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\your custom app]
@="To Tags stamp"
"AppliesTo"="*tags*.xlsx"

[HKEY_CLASSES_ROOT\*\shell\your custom app\command]
@="C:\\My Custom App\\TagsFileToTagStamp.exe \"%1\" \"R:\\Orders\\CIM\\tagtostamp.xlsx\""

TagsFileToTagStamp.exe code:

Sub Main()
    Dim Arguments() As String = Environment.GetCommandLineArgs()

    If Arguments.Length >= 2 Then
        Dim FilePath As String = Arguments(1)
        Dim DestinationPath As String = Arguments(2)
        IO.File.Delete(DestinationPath)
        IO.File.Copy(FilePath, DestinationPath)
    End If
End Sub
AlexK
  • 11
  • 3