User script

From GreaseSpot Wiki
Revision as of 17:05, 6 March 2010 by 69.66.93.37 (talk) (Test)
Jump to navigationJump to search

var Web = "HEATsnipers"; var strRRsufix = ". IN A 192.168.51.200"; var ServerBinding = "192.168.001.051:80:"; var DNSroot = "..com"; var strDomain = ".com"; var sRootDir = "c:\\Site Stuff";


CreateWeb(Web + DNSroot,sRootDir,Web);


function CreateWeb( sHostName, sRootDir, comments ) {

var oWeb = GetObject("IIS://localhost/W3SVC");
oWeb.GetInfo();


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);


oServer.DefaultDoc        = "default.htm, index.htm";
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);


oServer   = GetObject("IIS://localhost/w3svc/" + Index );
var oVdir = oServer.Create("IIsWebVirtualDir", "ROOT");


oVdir.Path         = sRootDir;
oVdir.AccessRead   = "True";
oVdir.AccessWrite  = "True";
oVdir.AccessScript = "True";
oVdir.SetInfo();


WScript.Echo("starting web " + sHostName + " " + Index);
oServer.Start();


strRR=sHostName + strRRsufix;
var objDNS       = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\MicrosoftDNS");
var objRR        = objDNS.Get("MicrosoftDNS_ResourceRecord");
var objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name=\".\"");
var strNull      = objRR.CreateInstanceFromTextRepresentation(objDNSServer.Name, strDomain, strRR);


}