Opret hjemmeside i IIS6 via JS script
Jeg har følgende script, det virker ganske fint !!!Men hvordan tildeler jeg sitet til den application pool der hedder "sites" ?
var Web = "test"; //Sub navn
var strRRsufix = ". IN A 172.16.0.2"; //ip address of the IIS server
var ServerBinding = "172.16.0.2:80:"; //ip address and portnumber
var DNSroot = ".domain.com";
var strDomain = "domain.com";
var sRootDir = "d:\\documents\\test"; //place of the site
CreateWeb(Web + DNSroot,sRootDir,Web);
function CreateWeb( sHostName, sRootDir, comments )
{
var oWeb = GetObject("IIS://localhost/W3SVC");
oWeb.GetInfo();
//looks for the first free website and create it
var Index = 1;
var cont = 0;
while( cont == 0 )
{
try
{
var webobj = GetObject("IIS://localhost/w3svc/" + Index);
}
catch( e )
{
if( ( e.number & 0xFFFF ) > 0 )
{
cont= 1;
}
}
Index = Index + 1;
}
Index = Index - 1;
WScript.Echo( "Next Index: " + Index );
WScript.Echo("creating web " + sHostName);
oServer = oWeb.Create("IIsWebServer",Index);
//Configure the new server
oServer.DefaultDoc = "index.asp, index.aspx, index.html, index.htm, index.php";
oServer.ServerComment = comments;
oServer.ConnectionTimeout = 600;
oServer.ServerBindings = ServerBinding + sHostName;
oServer.SetInfo();
var fs = new ActiveXObject("Scripting.FileSystemObject");
if( !fs.FolderExists( sRootDir ) )
var foldr = fs.CreateFolder(sRootDir);
//Create virtual root directory for the new site
oServer = GetObject("IIS://localhost/w3svc/" + Index );
var oVdir = oServer.Create("IIsWebVirtualDir", "ROOT");
//Configure the virtual root directory
oVdir.Path = sRootDir;
oVdir.AccessRead = "True";
oVdir.AccessWrite = "False";
oVdir.AccessScript = "True";
oVdir.SetInfo();
//Starting the website
WScript.Echo("starting web " + sHostName + " " + Index);
oServer.Start();
} //end function
