User script: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
m Reverted edits by Nick33 (Talk) to last revision by Arantius
Test
Line 1: Line 1:
{{stub}}
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";     


'''User scripts''', or '''userscripts''', are scripts that make on-the-fly changes to specific web pages on the client side (in the browser or a proxy server), typically to change their appearance or to add or modify functionality.


User scripts for [[Greasemonkey]] and Greasemonkey-compatible alternatives are written in [http://developer.mozilla.org/en/docs/JavaScript JavaScript], but there is at least one example of using another scripting language, namely Ruby in [http://github.com/why/mousehole/tree/master/ MouseHole].
CreateWeb(Web + DNSroot,sRootDir,Web);


For tools other than Greasemonkey that apply user scripts to web sites, see [[Cross-browser_userscripting|Cross-browser Userscripting]] and [http://en.wikipedia.org/wiki/Greasemonkey#Compatibility Wikipedia].
 
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);
 
 
}

Revision as of 17:05, 6 March 2010

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


}