views:

55

answers:

3

Is there an environmental variable or equivalent for WinZip32.exe I can use to find it's location path?

EDIT - This is an in house tool for a controlled system.

Thanks.

+2  A: 

You could access the registry and use look up what the associated program is for .zip files. That would be better anyway since not everyone uses WinZip.

jamesdlin
Except that USING the program may not be supported (i.e. different command line parameters) ;)
TomTom
...or you could use `FindExecutable` to find it instead of spelunking through (mostly undocumented) parts of the registry.
Jerry Coffin
@Jerry Coffin: Is FindExecutable pretty fast?
Tommy
@Tommy: to be honest, I've never tried to time it. When I've used it, it's mostly been followed (almost) immediately by spawning the executable in question, which is typically in the 100 ms range or something, so the contribution of FindExecutable doesn't mean much.
Jerry Coffin
@TomTom: You could look for the associated actions for the type, which will include the appropriate command line syntax.
jamesdlin
+1  A: 

The installers usually store useful information under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall but the actual key it's not always easy to find and the information stored varies from installer to installer.

It looks like WinZip (at least 14.5) is using an MSI based installer so you'll need to find it's key (in my case {CD95F661-A5C4-44F5-A6AA-ECDD91C240BD}) then read the InstallLocation key (full path HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{CD95F661-A5C4-44F5-A6AA-ECDD91C240BD}\InstallLocation).

P.S. If WinZip is too much trouble you can always go for one of it's many free alternatives that offer command line versions, like 7-Zip for instance, that you can install/copy in known location.

Eugen Constantin Dinca
+1  A: 

Is there an environmental variable or equivalent for WinZip32.exe I can use to find it's location path?

YOu probably can extract program location from registry. Most programs store their settings either in HKEY_LOCAL_MACHIN/Software/VendorName/ProgramName or HKEY_CURRENT_USER/Software/VendorName/ProgramName . Where VendorName is company's name and ProgramName is name of the program. Those settings MAY include installation path. And, of course, there is uninstall information somewhere in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall However, relying on either of them is not a good idea - settings format may change in next release, and some users (like me) tend to nuke extra values from registry even if they still have the program. So you can't guarantee that program is present if those values are set, and you can't guarantee that it isn't present if those values are missing.

The proper solution depends on what you're going to do with winzip.

If you want to extract *.zip files with your program, you have two options:

  1. Use some kind of library that handles zip files.
  2. Include compact *.zip-comptaible archiver (possibly command-line) with your program.

If you want to open files in winzip for the user, then proper way would be to open use whatever program is associated with *.zip on user's system instead of forcing user to use winzip. I believe that opening file using program (currently associated with that filetype) can be done with ShellExecute

SigTerm