How to set the framework version with IISVDIR ?

E

Elmue

Hello

I wrote a script which uses IISVDIR to add the .NET projects to the IIS.

The problem is that some ASPX solutions are written for framework 1.1
and others for framework 2.0.

I could not find a way how to programmatically set the framework
version.

Currently my script is quite useless as all framework 2.0 projects will
not run. I have to MANUALLY change the framework in the IIS Adminisrtator.

I want to run that 100% automatically.

Can anybody help me, please ?
Thanks.

Elmü
 
E

Elmue

Hello

I already found that the command

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe
-s w3svc/553851221/root/Path/MyAspxSolution

does what I need: convert an already existing 1.1 project into a 2.0
Project.

But where do I get the metabase number 553851221 from ?

All samples in the internet use a 1 (one) instead.
(w3svc/1/root)
But this does not work on my server.


Why does Microsoft make all so unneccesary complicated ??
I hate them!

Elmü
 
J

Juan T. Llibre

re:
!> But where do I get the metabase number 553851221 from ?

Run :

aspnet_regiis -lk

That will list the correct data you want, in the format :

W3SVC/somenumber/ROOT/AppName/ .NetVersionNumber
 
E

Elmue

Yeah !
I've got it !

The strange metabase number 553851221 seems to be a Hash which is
calculated from the name of the website.

It is only "1" if you run your webservice in the "Predefined Websites"

If I change the name the magic number also changes.
If I use the old name again the number is the same again.

So it is safe to use this number in your scripts as long as the name of
the website does not change in your script:

IIsWeb /create D:\Path\RootFolder "NameOfWebSite" /b 80

To get a list of all WebSites you can use this .NET code:


using System.DirectoryServices;

DirectoryEntry i_Parent = new DirectoryEntry("IIS://localhost/w3svc");

foreach (DirectoryEntry i_Entry in i_Parent.Children)
{
string s_Path = i_Entry.Path;

if (i_Entry.SchemaClassName == "IIsWebServer")
{
string s_Comment = i_Entry.Properties["ServerComment"]
.Value.ToString();

foreach (DirectoryEntry i_Dir in i_Entry.Children)
{
if (i_Dir.SchemaClassName == "IIsWebVirtualDir")
{
...
}
}
}
else if ((i_Entry.SchemaClassName == "IIsWebVirtualDir") ||
(i_Entry.SchemaClassName == "IIsWebDirectory"))
{
...
}
}


Elmü
 
E

Elmue

Hello

Now that my script has moved the website to run on framework 2.0
it still does not work.

Error: "The service is not available!"

I still have to manually set the AppPool to a pool that runs framework 2.0.

How can I change the Default App Pool for only one website via a script?

I havn't got a glimpse.

Elmú
 
E

Elmue

After one entire day of investigation I also solved the last problem:

Put this into a file "SetAppPool.vbs"


option explicit

Const GENERAL_FAILURE = 2
Const POOLED_PROCESS = 2
Const CREATE_POOL_IF_NOT_EXIST = true

If WScript.Arguments.Count < 2 Then
WScript.Echo
WScript.Echo
"-------------------------------------------------------------------------"
WScript.Echo "This script assigns a Web Application to a pool"
WScript.Echo "Usage: SetAppPool MetaPath PoolName"
WScript.Echo "If the name contains spaces the name must be enclosed
in quotation marks."
WScript.Echo "Example:"
WScript.Echo "SetAppPool W3SVC/553851221/Root/AppName Net2Pool"
WScript.Echo
"-------------------------------------------------------------------------"
WScript.Echo
WScript.Quit (GENERAL_FAILURE)
End If

Dim sWebApp
sWebApp = "IIS://localhost/" & WScript.Arguments.Item(0)

Dim IIsWebVDirObj
Set IIsWebVDirObj = GetObject(sWebApp)

IIsWebVDirObj.AppCreate3 POOLED_PROCESS, WScript.Arguments.Item(1),
CREATE_POOL_IF_NOT_EXIST
IIsWebVDirObj.SetInfo
 

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,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top