How to get the installed WebSite in VS2005 WebSetup installer customAction?

J

jacky kwok

Dear All:

In VS2005 WebSetup installer InstallAddress dialog, there is field to
let user to select which website to install the webapp (if there are
more than one WebSite in the IIS).

I want to know how can I get the WebStie info in the customAction.

I can use "/VDIR=[TARGETVDIR]" in customActiondata to get the installed
VirtualDirectory.
However, I cannot find any info how to receive the "WebSite" info.

There is a old example,
http://msdn.microsoft.com/library/d...internetinformationserverduringdeployment.asp

to use "/PORT=[TARGETPORT]" to find out the Site, but it does not work
in VS2005 websetup installer.


I need to website info to explicitly set the webapp to use ASPNET2.0 in
case of the machine to have multiple different version Dotnet runtime to
be installed.

The function to set the ASPNET runtime ,

http://www.asp.net/faq/SideBySide.aspx?tabindex=0&tabid=1

,need to use such format ,

aspnet_regiis -s w3svc/1/ROOT/VirtualDirectoy

for different website the "w3svc/[1]/ROOT/..." is different , e.g.
"w3svc/2/ROOT/..."


I need a method to get the information.


Thank you very much
 
Y

Yuan Ren[MSFT]

Hi Jacky,

Thank for posting!

For the current issue, my understanding is that you want to get the web
info via using ASDI for IIS. If I have misunderstood anything, please let
me know.

Based on my experience, the article you mentioned in the previous thread is
specified for IIS 5.0. So I want to know the current version of the IIS in
your machine. In another word, could you please tell my about the version
of the current OS?

BTW, I'll perform the test to figure out how to get the information for
IIS. It will take me some period to approach this. So, I appreciate your
understanding and patience. I'll reply you ASAP when I get some
information. If you have any concerns, please feel you free to let me know.

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
updated on February 14, 2006. Please complete a re-registration process
by entering the secure code mmpng06 when prompted. Once you have
entered the secure code mmpng06, you will be able to update your profile
and access the partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
J

jacky kwok

Yuan said:
Hi Jacky,

Thank for posting!

For the current issue, my understanding is that you want to get the web
info via using ASDI for IIS. If I have misunderstood anything, please let
me know.

Based on my experience, the article you mentioned in the previous thread is
specified for IIS 5.0. So I want to know the current version of the IIS in
your machine. In another word, could you please tell my about the version
of the current OS?

BTW, I'll perform the test to figure out how to get the information for
IIS. It will take me some period to approach this. So, I appreciate your
understanding and patience. I'll reply you ASAP when I get some
information. If you have any concerns, please feel you free to let me know.

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
updated on February 14, 2006. Please complete a re-registration process
by entering the secure code mmpng06 when prompted. Once you have
entered the secure code mmpng06, you will be able to update your profile
and access the partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================

Thank you very much.

In my case, I do not care what is the IIS version.
My question is I need to make the WebSetup installer which can set the
web application to suitable dotnet version in case of the machine has
multiple framweork installed.

The target machine may be XP or 2003, IIS may be 5 or 6.

In fact, I know how to queue how many websites in the IIS.

In VS2005 Websetup installer, user can select which website to install
the application in the Windows to input VirtualDirectory.

My main question is that how can I know my webapp has been installed in
which website? (in the customAction of the websetup installer)


i.e. "w3svc/1/ROOT/..." or "w3svc/2/ROOT/..." ...

Then my installer can set the suitable framework version by call script
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.xxxx\aspnet_regiis -s
w3svc/N/ROOT/..."
 
Y

Yuan Ren[MSFT]

Hi Jacky,

Thanks for your patience!

After my research, the example from the old MSDN article works well. You
can add the installer class in your current website project or create a new
project. Actually, the template of the installer class is supplied by the
windows form project and the class library project. However, we still can
use the installer class in our web project although there is no template.
So could you please give me more details about "but it does not work in
VS2005 websetup installer" you mentioned before?

BTW, if you don't want to use the managed class in the custom action of the
websetup project, I suggest you write a script to do this. The same ADSI
schema is appropriate for any kinds of custom actions such as script,
managed class, unmanaged class etc.

Hope this will be helpful!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 
J

jacky kwok

Yuan said:
Hi Jacky,

Thanks for your patience!

After my research, the example from the old MSDN article works well. You
can add the installer class in your current website project or create a new
project. Actually, the template of the installer class is supplied by the
windows form project and the class library project. However, we still can
use the installer class in our web project although there is no template.
So could you please give me more details about "but it does not work in
VS2005 websetup installer" you mentioned before?

BTW, if you don't want to use the managed class in the custom action of the
websetup project, I suggest you write a script to do this. The same ADSI
schema is appropriate for any kinds of custom actions such as script,
managed class, unmanaged class etc.

Hope this will be helpful!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support

I cannot understand how the "the example from the old MSDN article works
well".

I need to know which WebSite my Webapp installed in.

The old example did not mention anything about website.
The old example just use the "PORT" in customAction by adding the
"/PORT=[TARGETPORT]" in customActionData.

However, when I run the example code in the VS2005 WebSetup and
customAction,
"Context.Parameters.Item("Port")" always return empty.

I think it is because there no "port" can be selected in VS2005 web
installer.
("port" can be set in VS.NET 2002 web setup installer only).



In fact, in current time, I use a work around to solve my problem.
In customAction code, I can get the installing "VirtualDirectory".

I will loop through all the existing websites to check the
"VirtualDirectory" existing.

if the "VirtualDirectory" exists, set it to use ASPNET2.0.



then, I will loop through all

"w3svc/1/ROOT/VirtualDirectoy",
"w3svc/2/ROOT/VirtualDirectoy",
...




However, this method may be wrong if there is another webapp in some
other website using the same VirtualDirecory Name.
 
Y

Yuan Ren[MSFT]

Hi Jacky,

Sorry for misunderstanding!

My understanding is that you want to get the server number under the
"W3SVC" via the installation of the web site. If I have misunderstood
anything, please let me know.

During the installation, the site should be indicated. Actually, the site
here is the server comment of the current web server such as "Default Web
Site", "My Web Site" etc. As far as I know, we can use this name to get the
number which I mentioned before. The following script which I wrote is a
simple dome to demonstrate how to get the number:
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:{authenticationLevel=pktPrivacy}\\" _
& strComputer & "\root\microsoftiisv2")
Dim servercomment
servercomment = "Default Web Site"

Set colItems = objWMIService.ExecQuery("Select * from IIsWebServerSetting
where ServerComment = """ & servercomment & """")

For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Name: " & Right(objItem.Name, 1)
Next

The script works fine on my side. If you don't want to use the script as
the custom action in the setup project, you also can use it as managed
class which as the old document from MSDN does.

Hope this will be helpful!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 
J

jacky kwok

Hi Yuan Ren:

Thank you very much.


Your answer should a part of my question.

Following your code, I should get the website number from the website
name (I still do not test the code yet).

However, my problem does still exist.
The first problem I asked was "How can I know what is the website, which
the webapp installed in, in the websetup customAction".
In my case, the IIS server may have multiple websites. User can select
one which is not default one.

The problem is that I cannot ask the user to run another script to input
which website they have selected.
The websetup installer must be able to know the "website" in the
customAction program code automatically. The customAction code should
not prompt any UI to ask the user again.

I believe that there should be a name whish is something like the
"/VDIR=[TARGETVDIR]" which can be used to pass the isntalled
"VirtualDirectory" into the CustomAction.

I will imagine there is a , for example, "/SITE=[TARGETSITE]" which I
can input the CustomActionData field, then the installer will pass the
user selected "WebSite" to the customAction program code. Then, the
customAction code can get the "WebSite" by 'Context.Parameters["SITEV"]'.


However, I cannot find out how to do so.



Hi Jacky,

Sorry for misunderstanding!

My understanding is that you want to get the server number under the
"W3SVC" via the installation of the web site. If I have misunderstood
anything, please let me know.

During the installation, the site should be indicated. Actually, the site
here is the server comment of the current web server such as "Default Web
Site", "My Web Site" etc. As far as I know, we can use this name to get the
number which I mentioned before. The following script which I wrote is a
simple dome to demonstrate how to get the number:
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:{authenticationLevel=pktPrivacy}\\" _
& strComputer & "\root\microsoftiisv2")
Dim servercomment
servercomment = "Default Web Site"

Set colItems = objWMIService.ExecQuery("Select * from IIsWebServerSetting
where ServerComment = """ & servercomment & """")

For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Name: " & Right(objItem.Name, 1)
Next

The script works fine on my side. If you don't want to use the script as
the custom action in the setup project, you also can use it as managed
class which as the old document from MSDN does.

Hope this will be helpful!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 
J

jacky kwok

Dear All:

I just find out that

I actually can use the "/SITE=[TARGETSITE]" in the customActionData to
let the Installer to pass the "site" to the customAction code.

In past, I do not know how to find out the [name] of the site and I just
imagine there should be a [name] can be used.

However, I just thought that if the Installer can pass the "WebSite" to
the customAction, there should be some information have been put in the
installer itself.

Then, I tried to use "Orca" tool (a tool in the platform sdk) to examine
the websetup installer file "*.msi".
I just found that there was a key [TARGETSITE] in the "AdminUISequence"
table.
Then, I tried to use the "/SITE=[TARGETSITE]" in the customActionData.
I was very happy I could get the

'Context.Parameters["SITE"]=/LM/W3SVC/1'

It is more than just the site name. I can directly use the path in my case.



Anyway, thanks everyone who had given me comment to solve the problem.


--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk


jacky said:
Hi Yuan Ren:

Thank you very much.


Your answer should a part of my question.

Following your code, I should get the website number from the website
name (I still do not test the code yet).

However, my problem does still exist.
The first problem I asked was "How can I know what is the website, which
the webapp installed in, in the websetup customAction".
In my case, the IIS server may have multiple websites. User can select
one which is not default one.

The problem is that I cannot ask the user to run another script to input
which website they have selected.
The websetup installer must be able to know the "website" in the
customAction program code automatically. The customAction code should
not prompt any UI to ask the user again.

I believe that there should be a name whish is something like the
"/VDIR=[TARGETVDIR]" which can be used to pass the isntalled
"VirtualDirectory" into the CustomAction.

I will imagine there is a , for example, "/SITE=[TARGETSITE]" which I
can input the CustomActionData field, then the installer will pass the
user selected "WebSite" to the customAction program code. Then, the
customAction code can get the "WebSite" by 'Context.Parameters["SITEV"]'.


However, I cannot find out how to do so.



Hi Jacky,

Sorry for misunderstanding!

My understanding is that you want to get the server number under the
"W3SVC" via the installation of the web site. If I have misunderstood
anything, please let me know.

During the installation, the site should be indicated. Actually, the
site here is the server comment of the current web server such as
"Default Web Site", "My Web Site" etc. As far as I know, we can use
this name to get the number which I mentioned before. The following
script which I wrote is a simple dome to demonstrate how to get the
number:
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:{authenticationLevel=pktPrivacy}\\" _
& strComputer & "\root\microsoftiisv2")
Dim servercomment
servercomment = "Default Web Site"

Set colItems = objWMIService.ExecQuery("Select * from
IIsWebServerSetting where ServerComment = """ & servercomment & """")

For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Name: " & Right(objItem.Name, 1)
Next

The script works fine on my side. If you don't want to use the script
as the custom action in the setup project, you also can use it as
managed class which as the old document from MSDN does.

Hope this will be helpful!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 
Y

Yuan Ren[MSFT]

Hi Jacky,

I'm glad to hear the issue has been resolved:)

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top