How to associate a file extension to a program without making it the default program

后端 未结 5 1888
不思量自难忘°
不思量自难忘° 2021-01-12 06:38

I\'m deploying a small conversion tool on some systems, and want the users to be able to run it from the right click Open with menu. But I don\'t want to change

相关标签:
5条回答
  • 2021-01-12 07:24

    In the "File Types" Windows Dialog you can click "Advanced" on your file type and there create a custom action tied to your application.

    Possibly you can also find a way to do this in a programmatic manner, or at least create a .REG file with the equivalent registry options.

    0 讨论(0)
  • 2021-01-12 07:26

    You can add scripts to the context menu (below Open with) by adding it in the windows registry:

    1. Open regedit
    2. Goto HKEY_CLASSES_ROOT\your_class\Shell
    3. Add a new key and give it a name
    4. Edit the (Default) value of this key and insert the text you want to show in the context menu
    5. Add a new key named Command under your newly created key
    6. Edit the (Default) value of this key and insert the command you want to execute
    7. Enjoy!
    0 讨论(0)
  • 2021-01-12 07:27

    I have achieved the correct FILE ASSOCIATION using these cmd commands. (just an example):

    REG ADD "HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command" /v @ /t REG_SZ /d "\"C:\\Program Files\\Noteepad++\\notepad++.exe\" \"%1\"" /f
    REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt" /v "Application" /t REG_SZ /d "notepad++.exe" /f
    REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithList" /v "g" /t REG_SZ /d "notepad++.exe" /f
    
    assoc .txt=MyCustomType
    ftype MyCustomType="C:\Program Files\Noteepad++\notepad++.exe" "%1"
    

    (it's better to put them in .bat file)

    0 讨论(0)
  • 2021-01-12 07:29

    here's a worked example for XP adding a command prompt option to folders. Create a .reg file

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\shell\Command Prompt]

    [HKEY_CLASSES_ROOT\Directory\shell\Command Prompt\command] @="cmd.exe /k cd \"%1\""

    0 讨论(0)
  • 2021-01-12 07:41

    Setting the following keys worked for me:

    key HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/App Paths/<progname>: "" = <appPath>
    
    key HKCR/Applications/<progname>/SupportedTypes: <fileExt> = ""
    key HKCR/<fileExt>: "" = <progID>
    
    key HKCR/<progID>/OpenWithList/<progName>
    key HKCR/<fileExt>/OpenWithList/<progName>
    key HKCR/SystemFileAssociations/<fileExt>/OpenWithList/<progName>
    
    delete key and subkey at HKCU/SOFTWARE/Microsoft/Windows/CurrentVersion/Explorer/fileExts/<fileExt>
    
    0 讨论(0)
提交回复
热议问题