This blog is a knowledge base...where I clip cool tricks and urls

C# WMI to configure VirtualDirectory

clipped from channel9.msdn.com

' Add a virtual directory to the site. This requires SpawnInstance().
Set vdirClassObj = providerObj.Get("IIsWebDirectorySetting")
Set vdirObj = vdirClassObj.SpawnInstance_()
vdirObj.Name = strNewVdir
vdirObj.AuthFlags = 5 ' AuthNTLM + AuthAnonymous
vdirObj.EnableDefaultDoc = True
vdirObj.DirBrowseFlags = &H4000003E ' date, time, size, extension, longdate

vdirObj.AccessFlags = 513 ' read, script

' Save the new settings to the metabase

vdirObj.Put_()
ManagementClass clsIIsWebDirectorySetting = new ManagementClass(scope, new ManagementPath("IIsWebDirectorySetting"), null);
ManagementObject dir = clsIIsWebDirectorySetting.CreateInstance();
dir.Properties["Name"].Value = "W3SVC/" + account + "/ROOT" + path;

dir.Put()
 blog it

1 comment:

pay per head service said...

Its so interesting article..Thanks for sharing..