PDA

View Full Version : How to create IIS Virtual Directory using WSH



gidduk
12-24-2001, 08:53 AM
How to create Virtual Directory using WSH. I Want to create a virtual directory where my vbs file is put up. The default admin scripts does not help as I have to pass a lot of parameters.

darkness
01-22-2002, 09:30 PM
Just tackled this problem last friday here is a snipit that displays the current websites hosted:

'Enumerate and name the web sites.
set myIIS = getobject("IIS://mywebserver/W3SVC")
for each site in myIIS
if isnumeric(site.name) then
sline = sline & site.name & vbtab & site.servercomment & vbcrlf
end if
next
wscript.echo sline

Here is the code to generate a virtual directory:

set oIIS = getobject("IIS://mywebserver/W3SVC/4/ROOT")
on error resume next
set oVirtualdirectory = OIIS.create("IISWebVirtualDir", "VirtualDirectoryName")
oVirtualdirectory.setinfo
oVirtualdirectory.path = "c:\myVD"
oVirtualdirectory.EnableDirBrowsing = 1
oVirtualdirectory.AccessRead = 1
oVirtualdirectory.Accesswrite = 1
oVirtualdirectory.setinfo

Here ya go hope it helps you. Ideally you create to small functions/subroutines to do this in a larger program.


Michael McLaughlin/images/forums/icons/smile.gif
Systems Manager
Minnesota State University Mankato