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 Thanks red_fiesta
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
Hi red_fiesta I tried to get this to work about 10 months ago but failed, since when I've created 950 virtual directories by hand. I'll try to find some time to look into it again tomorrow - maybe we can crack it! cheers Garve
Hello You can directly goto control panel settings in that click on 1) click on IIS manager 2) right click on defalut web site 3) select new virtual directory 4) browse and select the virtual directory 5) browse and select the actula folder 6) click on finish It creates virtual directory then check the url with local host.... Hope u got it, if not search it in google Thanks KSoft
Ronal - I think red_fiesta knows that - what he and I are looking for is a way to create virtual directories using ASP rather than through the Internet Services Manager. red_fiesta - I had a look at the Microsoft page - it says When you install Microsoft Windows NT Server version 4.0 and IIS, ADSI sample scripts and the WSH environment are installed by default. and When you install IIS, the sample IIS Admin Objects scripts are copied into the following directory by default: %windir%\System32\Inetsrv\AdminSamples. However, I can't find that directory on my server (Windows 2000 server) so I don't know whether the ADSI stuff has been installed.
http://www.installshield.com/news/newsletter/0205-articles/virtual-directory.htm has another vbscript example, but I think it'll fail at the first hurdle too. http://www.iiscontrol.com is a component which claims to let you create virtual directories, but though the website looks OK there's very little info there.
Hi red_fiest - if you're still around? I've got past the Permission Denied thing using this. http://www.iisfaq.com/Default.aspx?tabid=2990 cheers Garve
Hi again Red_fiesta - I've cracked it and am now able to set up virtual directories on my server using an ASP page! Your thread kicked me into gear on this again - I'm now in a position to let users create their own sites at the click of a button if I want to - haven't decided on that yet. cheers Garve
Hey I don't know if this topic is still hot but I have a question regarding this. I recently have been asked to create a virtual dir using ASP, now using the code here I get to the same error however the link provided by Garve tells me to create a user with a password... Sorry to say I'm not very good with ASP as of yet, but the way to add users is not going to work because I don't have any admin rights. Is there still a way to create a virtual directory (without admin right and no local IIS)? My PC is connected to a server from my work and also to the local network, which should have IIS on it but I dunno how to check it. Any help is appreciated ^^