clodaghm
asked on
ADSI - auto creation of virtual directory using ASP&VBScript
Hi,
I'm trying to automatically generate virtual directories using ADSI. However, when I try to run the script I've written, I get an error (error '80005004') at the line
Set vDir = vRoot.Create("IIsWebVirtua lDir",sVir Dir)
where -sVirDir is the name of the virtual dir. to be created, i.e."Test".
-vRoot is defined as:
set vRoot = websvc.GetObject("IIsWebVi rtualDir", "ROOT") .
I'm running the script on NT Workstation - can virtual directories only be created on NT Server? If not, can you tell what's wrong with my code?
I'm a little concerned about the permissions needed to actually run this script; for the virtual directory from which this script is run (in Internet Service Manager), they are set as NT Challenge/Response. Should anonymous authentication be enabled too (note, I've tried this too and I still get the same error!)?
Thanks a lot
Clo
********Here's the whole script***************
<html>
<body>
<%
sComputer ="localhost"
sPhyDir = "d:\inetpub"
sVirDir = "Test"
'Get Default Web Site Object
set websvc = GetObject("IIS://" & sComputer & "/W3svc/1")
'Verify by printing out ServerComment
'Response.Write "Comment = " & websvc.ServerComment & "<br>"
'Get root of Default Web Site
set vRoot = websvc.GetObject("IIsWebVi rtualDir", "ROOT")
'Get Class Definition of virtual directory
Set ClassDefinition = GetObject(vRoot.Schema)
'Create Virtual Directory
Set vDir = vRoot.Create("IIsWebVirtua lDir",sVir Dir)
'Only setting two properties
vDir.AccessRead = true
vDir.Path = sPhyDir
'Write information back to Metabase
vDir.SetInfo
%>
</body>
</html>
I'm trying to automatically generate virtual directories using ADSI. However, when I try to run the script I've written, I get an error (error '80005004') at the line
Set vDir = vRoot.Create("IIsWebVirtua
where -sVirDir is the name of the virtual dir. to be created, i.e."Test".
-vRoot is defined as:
set vRoot = websvc.GetObject("IIsWebVi
I'm running the script on NT Workstation - can virtual directories only be created on NT Server? If not, can you tell what's wrong with my code?
I'm a little concerned about the permissions needed to actually run this script; for the virtual directory from which this script is run (in Internet Service Manager), they are set as NT Challenge/Response. Should anonymous authentication be enabled too (note, I've tried this too and I still get the same error!)?
Thanks a lot
Clo
********Here's the whole script***************
<html>
<body>
<%
sComputer ="localhost"
sPhyDir = "d:\inetpub"
sVirDir = "Test"
'Get Default Web Site Object
set websvc = GetObject("IIS://" & sComputer & "/W3svc/1")
'Verify by printing out ServerComment
'Response.Write "Comment = " & websvc.ServerComment & "<br>"
'Get root of Default Web Site
set vRoot = websvc.GetObject("IIsWebVi
'Get Class Definition of virtual directory
Set ClassDefinition = GetObject(vRoot.Schema)
'Create Virtual Directory
Set vDir = vRoot.Create("IIsWebVirtua
'Only setting two properties
vDir.AccessRead = true
vDir.Path = sPhyDir
'Write information back to Metabase
vDir.SetInfo
%>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your code seems to be ok. You can take a look on one of my previous answers
https://www.experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=10179526
I dont think that the NT Workstation is a problem. The most probable thing from my point of view are the permissions.
Also, you are sure that "vRoot" is a valid object? You are sure that you have not already created "Test" vDirectory?