Anyone know how to reliably delete a Registry Key?

BACKGROUND:
Previous version so my app in Windows have used Advanced Installer to install, and to associate the app with the file extension.
Stupidly, last year, the exe name contained the year name Myapp2012.exe
MyFileType is associated with that.

This years version would be called Myapp2013.exe or (having learned my lesson) just Myapp.exe
But That damned windows installer keeps trying to re-install last years version when anyone double clicks a document of MyFileType.

I need to find the bits that the registry uses to even know where the MSI file for last year lives, and the file association.

It seems that many apps can ‘own’ a file extension (obvious, as many would like to be able to handle JPgs), but trying to set or clear the DEFAULT one is a nightmare.

PROBLEM:
Any code I can find for using the registry, FAILS to delete the key.
Does anyone know why, or have any reliable code to show me how its done?
(I have the MBS plugins too, and cant make them work either, but the documentation is really short on examples)

[quote=14519:@Jeff Tullin]BACKGROUND:
Previous version so my app in Windows have used Advanced Installer to install, and to associate the app with the file extension.
Stupidly, last year, the exe name contained the year name Myapp2012.exe
MyFileType is associated with that.

This years version would be called Myapp2013.exe or (having learned my lesson) just Myapp.exe
But That damned windows installer keeps trying to re-install last years version when anyone double clicks a document of MyFileType.

I need to find the bits that the registry uses to even know where the MSI file for last year lives, and the file association.

It seems that many apps can ‘own’ a file extension (obvious, as many would like to be able to handle JPgs), but trying to set or clear the DEFAULT one is a nightmare.

PROBLEM:
Any code I can find for using the registry, FAILS to delete the key.
Does anyone know why, or have any reliable code to show me how its done?
(I have the MBS plugins too, and cant make them work either, but the documentation is really short on examples)[/quote]

On windows 7 you should be able to do it by:

  1. Right mouse click on file with the file extension you wish to be default for new application
  2. Select Open with --> Choose Default program from pop-up window
  3. Make sure check box (Always use the selected program to open this kind of file) is check
  4. Select browse button and select your application you want to open your file with.

Right mouse click on file with the file extension you wish to be default for new application
Select Open with → Choose Default program from pop-up window<<

Thanks John.
But although thats fine for me, I know how to do that on my own machine.

I have thousands of users. I can’t ask them all to do that.
This is an install issue, and a registry issue.

To be clear, Ive found a bunch of keys that were written by the previous installer, and I need to remove them to make this years version work cleanly.
RegistryKey.delete(string) fails to work
maybe I dont know what that should look like: There is no explanation of what RegistryKey should be initialsed to, and what string should contain.
I’d like to say ‘Ive tried everything’ but that wont be true: the thing that works will be the thing I havent tried.

[quote=14523:@Jeff Tullin]To be clear, Ive found a bunch of keys that were written by the previous installer, and I need to remove them to make this years version work cleanly.
RegistryKey.delete(string) fails to work
maybe I dont know what that should look like: There is no explanation of what RegistryKey should be initialsed to, and what string should contain.
I’d like to say ‘Ive tried everything’ but that wont be true: the thing that works will be the thing I havent tried.[/quote]

I presume you know how to use command: regedit to find all the lines you wish to be deleted.

To delete a registry you will need command: reg
Enter reg /? to see all options.
And for more options on delete enter: reg delete /?

Lets talk about the registry and permissions for a moment. On most modern systems, installers get some form of elevated privileges just to be able to install the program in the right places. The chances that you’ll be able to modify those registry keys from another program without installer or higher level access is rather slim.

My suggestion would be to have a new installer this year that registers THIS year’s program as the designated opener of your file extension. You should be able to write some commands into AI to remove previous keys as well, the capabilities are quite extensive.

Also, this year consider making rules in your installer for your application so that if the user uninstalls the app, it’ll take the appropriate keys with it. That way you won’t run into this again.

Looks like that is what I am up against

That appears to be almost as difficult.
I can certainly associate the new app with the extension, but it doesnt claim it as default.
AI has a default application setting, but if I use that I get an error during the install to say that some component (of windows?) is missing, and it wont play.

Doing ‘default program’ by hand sets a registry key of UserChoice which is nothing like the settings that AI creates.

I’ve begun considering that now. Havent worked out how to do it, but piggybacking the elevated privileges sounds like a start

Now there is my main beef with AI.
I use an installer so that I don’t have to worry about this kind of thing.
Uninstall should run through the install log it created and undo the lot. That’s just obvious.
Theres no settings for this, its installer 101, surely?

never did resolve this one

The real problem is that it’s not possible to set the execution level of Xojo apps when running on Windows which causes registry updates to be ignored or generate exceptions when UAC is turned on. This project will launch a Xojo generated program with UAC elevated privileges. Read the comments in the App.run event on usage.