IBM developerWorks
 
       ASP.NET
  Home arrow ASP.NET arrow WSH Script to setup .NET Quickstarts in ot...
Click Here
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

WSH Script to setup .NET Quickstarts in other Websites besides the Default Website
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 4
    2002-01-29

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    WSH Script to setup .NET Quickstarts
    in other Websites besides the Default Website

    This article is for people who want to host the .NET Quickstarts on a Top-Level Domain besides the Default Website inside IIS. This windows scripting host file is something I (Steve Schofield) whipped up to create the 55 or so virtual application roots for the Quickstarts that come with the .NET framework SDK. Instead of having to manually create these inside using Internet Service Manager, this script will take care of it. By default the .NET Quickstarts are installed to the Default website. This script creates them in the Top-Level Domain you define in the setup.vbs file. The script accepts three arguments, (Path of Directory, physical path of directory, friendly application root name) 

    wscript setup.vbs Quickstart "C:\Program Files\Microsoft.NET\FrameworkSDK\Samples\QuickStart\" Quickstart

    This script creates an application root called Quickstart and the 50+ directorys in the IIS Metabase in the Website you define in the script.   ASPFree.com server has multiple top-level domains,  we've hosted the Quickstarts from day one, visitors have come to expect these and we want to continue offering the service.   This script is only really intended to be used by people who plan on hosting the Quickstarts outside the Default Website.   I nor does aspfree.com take no responsibility of running the script and causing problems on your system.  Practice safe adminstrative methods (that means back up your IIS metabase and test before JUST deploying to a production machine),  this uses ADSI to create the directories.  Before running this on any server, test out.  This has been tested on Windows 2000 servers only.

    PS: In the Setup.vbs file, replace the "bigdogsbowling" with the name of your website name. From what I could determine, this was case sensative.

    Here is the script code 

    On Error Resume Next

    Dim ArgObj ' Object which contains the command line argument
    Dim Result ' Result of the command function call
    Dim Args(10) ' Array that contains all of the non-global arguments
    Dim ArgCount ' Tracks the size of the Args array
    Dim vAppFriendlyName

    dim vPath, scriptPath,vName

    'Set object to command line arguements
    Set ArgObj = WScript.Arguments

    'Name of virtual web
    vName = ArgObj(0)

    'Path to the files
    vPath = ArgObj(1)

    'appFriendlyName from command line
    vappFriendlyName = ArgObj(2)

    'call to create vDir
    CAll CreateVDir(vName, vPath, vappFriendlyName)

    'code taken from mkwebdir.vbs and changed for single vDir creation.
    Sub CreateVDir(byVAl vName, byVal vPath, byVal vappFriendlyName)

    Dim vRoot,vDir,webSite
    On Error Resume Next

    ' get the local host default web or change to the web you want
    ' replace bigdogsbowling with the name of your website defined inside Internet Svc Manager
    ' This is case sensative as far as we could tell
    set webSite = findWeb("localhost", "bigdogsbowling")
    if IsObject(webSite)=False then
    Display "Unable to locate the Default Web Site"
    exit sub
    else
    'display webSite.name
    end if

    ' get the root
    set vRoot = webSite.GetObject("IIsWebVirtualDir", "Root")
    If (Err <> 0) Then
    Display "Unable to access root for " & webSite.ADsPath
    Exit sub
    else
    'display vRoot.name
    End IF

    ' delete existing web if needed
    ' vRoot.Delete "IIsWebVirtualDir",vName
    ' vRoot.SetInfo
    Err=0 ' reset error

    ' create the new web
    Set vDir = vRoot.Create("IIsWebVirtualDir", vName)
    If (Err <> 0) Then
    Display "Unable to create " & vRoot.ADsPath & "/" & vName & "."
    exit sub
    else
    'display vdir.name
    end if

    ' set properties on the new web
    vDir.AccessRead = true
    vDir.Accessflags = 513
    vDir.Path = vPath
    vDir.appFriendlyName = vappFriendlyName
    vDir.appIsolated = 0
    VDir.AppCreate False
    If (Err <> 0) Then
    Display "Unable to bind path " & vPath & " to " & vRoot.Name & "/" & vName & ". Path may be invalid."
    exit sub
    end If

    ' commit changes
    vDir.SetInfo
    If (Err <> 0) Then
    Display "Unable to save changes for " & vRoot.Name & "/" & vName & "."
    exit sub
    end if

    ' report all ok
    ' WScript.Echo Now & " " & vName & " virtual directory " & vRoot.Name & "/" & vname & " created successfully."
    End Sub

    Function findWeb(computer, webname)
    On Error Resume Next

    Dim websvc, site
    dim webinfo
    Dim aBinding, binding

    set websvc = GetObject("IIS://"&computer&"/W3svc")
    if (Err <> 0) then
    exit function
    end if
    ' First try to open the webname.
    set site = websvc.GetObject("IIsWebServer", webname)
    if (Err = 0) and (not isNull(site)) then
    if (site.class = "IIsWebServer") then
    ' Here we found a site that is a web server.
    set findWeb = site
    exit function
    end if
    end if
    err.clear
    for each site in websvc
    if site.class = "IIsWebServer" then
    '
    ' First, check to see if the ServerComment
    ' matches
    '
    If site.ServerComment = webname Then
    set findWeb = site
    exit function
    End If
    aBinding=site.ServerBindings
    if (IsArray(aBinding)) then
    if aBinding(0) = "" then
    binding = Null
    else
    binding = getBinding(aBinding(0))
    end if
    else
    if aBinding = "" then
    binding = Null
    else
    binding = getBinding(aBinding)
    end if
    end if
    if IsArray(binding) then
    if (binding(2) = webname) or (binding(0) = webname) then
    set findWeb = site
    exit function
    End If
    end if
    end if
    next
    End Function

    function getBinding(bindstr)

    Dim one, two, ia, ip, hn

    one=Instr(bindstr,":")
    two=Instr((one+1),bindstr,":")

    ia=Mid(bindstr,1,(one-1))
    ip=Mid(bindstr,(one+1),((two-one)-1))
    hn=Mid(bindstr,(two+1))

    getBinding=Array(ia,ip,hn)
    end function

    Sub Display(Msg)
    WScript.Echo Now & ". Error Code: " & Hex(Err) & " - " & Msg
    End Sub

    Sub Trace(Msg)
    WScript.Echo Now & " : " & Msg
    End Sub

    Sub DeleteWeb(WebServer, WebName)
    ' delete the exsiting web (ignore error if missing)
    On Error Resume Next
    Dim vDir
    display "deleting " & WebName

    WebServer.Delete "IISWebVirtualDir",WebName
    WebServer.SetInfo
    If Err=0 Then
    DISPLAY "WEB " & WebName & " deleted."
    else
    display "can't find " & webname
    End If

    End Sub

     


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP.NET Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    Check out the new Jazz space on developerWorks

    <a href="http://zeus.developershed.com/shonuff.php?blackbird=3853&zoneid=442&source=&dest=http%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fspaces%2Fjazz%3FS_TACT%3D105AGY31%26S_CMP%3DDEVSHED&ismap="><img src="http://images.devshed.com/corp/img/news/jazz01.gif" alt="developerWorks Jazz space" align="left"></a>You've heard the buzz about Jazz... want to know more about it from a developer's perspective? Check out the Jazz space on developerWorks. This space is an up-to-date resource for developers, including technical information about Jazz and products built on Jazz, like Rational Team Concert Express. The Jazz space includes content from a wide variety of sources, including links, feeds, and comments from experts.
    FREE! Go There Now!


    NEW! Addressing software-as-a-service challenges using Tivoli security and WebSphere solutions

    Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base.
    FREE! Go There Now!


    NEW! Best Practices in Integrated Requirements Management

    Poor Requirements Management capabilities in an Enterprise have been linked to excessive project failures, escalating IT costs, and failure to deliver competitive advantage into the marketplace. Join Brianna M Smith from IBM Rational and learn about how successful organizations align IT and Business stakeholders through collaborative processes and tools for effective requirements management, and how an integrated approach across the IT lifecycle can provide unparalleled visibility and traceability to ensure that project teams are delivering on the business vision by "doing the right things" and "doing things right."
    FREE! Go There Now!


    NEW! Evaluate IBM Rational Software Analyzer V7.0

    Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle.
    FREE! Go There Now!


    NEW! Evaluate WebSphere Extended Deployment Compute Grid V6.1

    Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z: Architecture

    Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server.
    FREE! Go There Now!


    NEW! IBM Rational Systems Development e-Kit

    As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br />
    FREE! Go There Now!


    NEW! Project and Portfolio Management Executive Resource Kit

    Portfolio Management is about effectively managing portfolio value by aligning portfolio investments with business goals. This complimentary e-kit provides a collection of materials that can help you understand how IBM Rational enables and automates best practices for improved governance and clear visibility into portfolio and project performance across the entire IT project lifecycle.
    FREE! Go There Now!


    NEW! Rational Testing eKits

    Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing.
    FREE! Go There Now!


    NEW! Webcast: What is new in Viper 2 for developers?

    Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP.NET ARTICLES

    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...
    - Order-Related Modules for an ASP.NET AJAX Se...
    - User and Role Management for an ASP.NET AJAX...
    - Programming an ASP.NET AJAX Server-Centric B...

    BlackBerry VTS




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway