Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File associations for "edit", "print", etc. 1

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,512
Scotland
I am in the process of setting up an old Windows 7 machine that has (literally) been gathering dust in my office for several years. Basically, it works fine. But I'm stuck on how to set up file associations.

I know how to associate a file extension with an application (Control Panel -> Programs -> Set your default programs). But that only sets the "open" action. I also want to set "edit" and "print" actions, where these are available.

For example, if I double-click on a JPG, it opens in the default file viewer, which is fine. But I'd also like to be able to right-click and choose "edit" so that it opens in my image editing program. Similarly, an HTML file would open in a browser, but it would be edited in a text editor.

I know this was possible in XP (if any of you can remember that far back), but I can't see any way of doing it in 7.

Thanks in advance for your help.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks for your fast reply. I read the article you linked to. It suggests a variety of utilities for editing the context menu. But at first glance none of them appear to answer my question. I can see how to add and remove items from the context menu. But what I need to know is how to associate commands such as "edit" and "print" with specific functions within an application.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
>I know this was possible in XP

Are you quite sure? I don't recall such built-in functionality. As with W10 there were third party tools (e.g. ShellMenuView) that gave you some control over the context menu. But it is limited (as I guess you have found). Mainly because there is no generic method of telling an application how you want it to handle a file (e.g Notepad and Wordpad require a commandline parameter to be passed to print a document:

%SystemRoot%\system32\NOTEPAD.EXE /p %1

whereas printing an Excel file involves a specific call into a shared Office DLL)

Still, if you know the class that the filetype is registered under you can add pretty much any command to do ppretty much anything you like.

For example, to add a command called wombat that opens a a command prompt when rightclicking a .txt file, all you need to know is that that is registered as [tt]txtfile[/tt]

So you just need to open RegEdit and find

[tt]Computer\HKEY_CLASSES_ROOT\txtfile[/tt]
Open the [tt]shell[/tt] key, and add a new key called [tt]wombat[/tt]
Slect the keyu you've just add a subkey called [tt]command[/tt]
Set the default value of [command] to the actual command you want to run - in this case simply [cmd]

And you are done. FInd a ,txt file, right-click and wombat shpuld be there. CLicking it should launch a command prompt

So, as long as you know the command you need to run, you can do this relatively easily manually.

As ever the standard disclaimer - be aware that manually editing the registry can cause problems. Always take a backup of the registry first.

Also be aware that the context menu is actually built from multiple sources, so there is the risk that your command name may conflict with one from another source ...


 
Strongm, many thanks for your detailed reply, which made good sense.

Regarding the feature being available in XP, you wrote:

Are you quite sure? I don't recall such built-in functionality.

Yes. There was an interface in the Folder Options dialogue in the Explorer window:

xp-2_vkxup5.jpg



You could specify the required actions here, and these appeared on the context menu:


xp-1_t8xqzv.jpg



I understand your point about having to associate the action (such as "print") with a specific command (such as a command-line parameter). I can do that. What I was looking for was a way of getting that command onto the context menu.

Actually, it's a bit simpler than that. In many cases, I don't need a special command to perform the action, but simply the name of another program. For example, in the case of an HTML file, the main action would be to open the file in a web browser. The "edit" action would be to open the file in a text editor.

So, in the absence of the Folder Options dialogue in the Explorer window (why on earth did they decide to remove it?), it looks like I will have to resort to editing the registry manually.

Another approach might be to add the relevant programs to the "Open with" sub-menu. But that only seems to be available for some file types and not others. I wonder if there is a way of dealing with that?

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Or try [link Defaultprogramseditor.com]defaultprogramseditor.com[/url]
 
Just to wrap this up ....

I am going with Strongm's advice and manually adding items to the context menu by editing the relevant registry entries. It looks easier than I first thought, especially as, in most case, the required command is simply to open the relevant program (such as a text editor in my HTML example above).

Thanks also for the link to Default Program Editor. I'm keeping that in reserve.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top