Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2006, 04:29 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default creating new virtual directory

 Is there a way in asp to create a new default web site within IIS

I am setting a content managament system and want to create a new default web site during on of the processes.

So for example if people create a new site within the admin section and call it Jacinto this will create a new virtual directory called Jacinto.

This would then be accessed at http://localhost/jacinto


I have tried this code

<%
'''''''''''''''''''''''''''''''''
' ADSI ASP Sample Program
' This is a sample of how to create a virtual directory using ADSI.
'
'''''''''''''''''''''''''''''''''
Option Explicit
On Error Resume Next

'''''''''''''''''''''''
' First, open the path to the Web server you are
' trying to add a virtual directory to.

Dim ServObj
Dim VdirObj
Dim Testpath

Set ServObj = GetObject("IIS://LocalHost/w3svc/1/Root")
if (Err <>0) then
Response.Write "GetObject (""IIS://LocalHost/w3svc/1/Root"") Failed! <br>"
Response.Write "Error! " & Err.Number & "(" & Hex(Err.Number) & "): " & Err.Description & "<br>"
Response.End
end if

'''''''''''''''''''''''
' Second, Create the virtual directory (Vdir) path
Set VdirObj = ServObj.Create("IIsWebVirtualDir", "MyVdir")
VdirObj.SetInfo
if (Err<>0) then
Response.Write "CreateObject (""IIS://LocalHost/w3svc/1/Root/MyVdir"") Failed!<br>"
Response.Write "Error! " & Err.Number & "(" & Hex (Err.Number) & "): " & Err.Description &

"<br>"
Response.End
end if

''''''''''''''''''''''''
' Finally, create a Path variable containing the virtual root path and
' set the permissions to read, script, and directory browsing
VdirObj.AccessRead = True
VdirObj.AccessScript = True
VdirObj.EnableDirBrowsing = True
Testpath = "C:\Temp"
VdirObj.Put "Path", (Testpath)

VdirObj.SetInfo
if (Err<> 0) then
Response.Write "Put (""Path"") Failed!"
Response.Write "Error! " & Err.Number & "(" & Hex (Err.Number) & "): " & Err.Description &

"<br>"
Response.End
end if

Response.Write "VDIR successfully created"

''''''''''''''''''''''''
' The minimum amount necessary to create a virtual directory has now
' been completed. If you need to add more, do it here.

%>

from http://msdn2.microsoft.com/en-us/library/ms951564.aspx

But i get

GetObject ("IIS://LocalHost/w3svc/1/Root") Failed!
Error! 70(46): Permission denied

I have put this file in a dir and given it all permssions..

please help

This is vital





Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Directory MeenaG BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 December 2nd, 2006 01:48 PM
creating new virtual directory red_fiesta Classic ASP Professional 14 October 26th, 2006 12:19 PM
Virtual Directory kristina BOOK: Beginning ASP 3.0 1 April 22nd, 2005 09:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.