ASP.NET
  Home arrow ASP.NET arrow WSH Script to setup .NET Quickstarts in ot...
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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


    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!


    IBM DB2 Deep Compression ROI Tool

    The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times.
    FREE! Go There Now!


    IBM – Taking Web 2.0 to Work

    You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! IBM – Taking Web 2.0 to Work

    David Barnes, Lead Evangelist for IBM Emerging Internet Technologies will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! Develop Systems Software Assets with IBM Rational Asset Manager

    Join us for this on demand webcast to learn about developing complex systems more quickly and efficiently. We'll cover market drivers for developing, governing and reusing systems software assets and how you can develop system software assets with Rational Asset Manager.
    FREE! Go There Now!


    NEW! Evaluate Rational Business Developer V7.1

    Visit IBM developerWorks to download a free trial version of IBM Rational Business Developer V7.1. Rational Business Developer offers rapid and simplified development of business applications and services through Enterprise Generation Language (EGL) tools, generating Java or mainframe solutions while shielding developers from technical complexities.
    FREE! Go There Now!


    NEW! Hacking 101

    Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today.
    FREE! Go There Now!


    NEW! Hello World: WebSphere Service Registry and Repository

    Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z

    IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects.
    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! Webcast: Application security testing and Web compliance

    Join the IBM Watchfire team for an informative discussion on techniques and best practices to proactively manage Web application security and how to effectively build application security testing into the software development lifecycle (SDLC). In this Software Delivery Platform webcast you will learn: How to better understand potential web application security vulnerabilities, best practices and how to effectively integrate application security testing into the software development lifecycle, the importance of detecting and removing software vulnerabilities during application development.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP.NET ARTICLES

    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...
    - Building an In-Text Advertising System Under...
    - Developing a Mini ASP.NET AJAX Server Centri...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT