views:

216

answers:

2

I have a asp.net project, and wrote a web installer. The setup exe/msi copies that project in directory chosen by the installing user, and creates an application for it.

How can I get the path my asp.net application got installed to (in the installer)? I want to write the physical path of my ASP.net application into the registry, because a windows service needs to watch a directory of this web project, and it can't do that, unless it knows where the web project was installed to.

Does the Webinstaller project by any chance write this value into the registry automatically ?

A: 

Unfortunately no; IIS uses means other than the registry to store its configuration.

For IIS4, IIS5 and IIS6, you'll need to take a look through the IIS Metabase. This is an XML file in your Windows folder under system32\inetsrv\Metabase.xml; it's XML, so you should be able to read it directly to find the information you need.

IIS7 doesn't use the Metabase any more; instead, see here for details of the managed API to the IIS configuration.

So you may find it best to rework your application to look in either of these places for the directory information that you need.

Jeremy McGee
A: 

It is possible:

Right-click on the setup project, and choose View->Registry from the context menu.
Right-click on HKEY_Local_Machine, add a new key, call it Software.
Right click on Software, add a new key, call it "MyCompanyName".
Right click on MyCompanyName, from the context-menu, choose new->String call it installation folder.
Left click on the installationFolder key, and set property value to [TARGETDIR]
Add an additional string key, call it version and give it the value [ProductVersion]

including the []


On x64, you'll find your registry key in regedit under
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\YourCompany]


But programmatically, you can read it normally, from normal projects and web projects, with:
My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\YourCompanyName", "Installation Folder", Nothing)

Quandary