rem
rem CopyRight (C) 2000-2001 Microsoft Corporation. All Rights Reserved.
rem
rem Create iis virtual directory for tsweb and delete this file itself
rem

Dim strSystemDir
Dim strSystemDrive
Set WshShell = CreateObject("WScript.Shell")
strSystemRoot = WshShell.ExpandEnvironmentStrings("%SystemRoot%")


const NS_IIS = "IIS://"

rem
rem create a new virtual root for the Server Appliance administration
rem
Call CreateVroot ( "localhost", "tsweb", strSystemRoot + "\web\tsweb" )
Call DeleteAFile (strSystemRoot + "\web\tsweb\" + "tsweb_setup.vbs")


rem 
rem Function to Create Virtual Directory
rem Arguments: 
rem 	sHost -	name of the server to create virtual root on
rem	vRoot - name of the virtual root to create
rem     sPath - directory on server where the vroot points
rem
Function CreateVroot (sHost , vRoot , sPath) 

    on error resume next
    g_sErrInfo = ""
    g_bCancel = False
  
    Dim oWebShare , oWebRoot , oFs
    
    '// Ensure physical Path exists
    Set oFs = CreateObject("Scripting.FileSystemObject")
    If Not (oFs.FolderExists(sPath)) Then
        Call oFs.CreateFolder(sPath)
    End If

    rem
    rem get the root of the default web site
    rem
    Set oWebRoot = GetObject(NS_IIS & sHost & "/w3svc/1/root")
    
    rem
    rem create a virtual root below that
    rem
    Set oWebShare = oWebRoot.Create("IISWebVirtualDir", vRoot)
    
    rem
    rem set properties for this vroot
    rem
    oWebShare.AuthAnonymous = True
    oWebShare.AuthBasic = True
    oWebShare.AuthNtlm = False
    
    oWebShare.Path = sPath 
    oWebShare.AccessRead = True
    oWebShare.AccessWrite = False
    oWebShare.AccessExecute = False
    oWebShare.AccessScript = True
    oWebShare.AppCreate (True)
    oWebShare.AppFriendlyName = "Terminal Server Web Client"
    
    oWebShare.SetInfo
  
 End Function

rem
rem	Delete this file
rem
Function DeleteAFile(filename)
    Dim fso
    set fso = CreateObject("Scripting.FileSystemObject")
    fso.DeleteFile(filename)
End Function


