cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ekaet1
Level 2

setting default doc in IIS through installscript

Guys,
Any ideas on how to set a virtual directory's default document through installscript?

Thanks
Labels (1)
0 Kudos
(2) Replies
m_rudolph
Level 6

Try this vbscript:

strComputer = "."
Set objWMIService = GetObject _
("winmgmts:{authenticationLevel=pktPrivacy}\\" _
& strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
("Select * from IIsWebServiceSetting")

For Each objItem in colItems
strDocs = objItem.DefaultDoc
objItem.DefaultDoc = strDocs & ",index.htm"
objItem.DefaultDocFooter = "FILE:c:\config\footer.htm"
objItem.EnableDefaultDoc = True
objItem.EnableDocFooter = True
objItem.Put_
Next
0 Kudos
SimonG
Level 5

Ancient thread I know but it's nice to have an answer for anyone searching for this question still...

For IIS 7 and 8 you need the metabase compatibility (Windows feature) installed to use these II6 metabase properties.

function UpdateDefaultDocSettings(virtualDirName)
OBJECT objIIS_Root, objVirtualDir;
begin
try
// Get the root IIS folder.
set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
set objVirtualDir = objIIS_Root.GetObject("IISWebVirtualDir", virtualDirName);
if (IsObject(objIIS_Root) && IsObject(objVirtualDir)) then
// Update the virtual directory.
objVirtualDir.Put("DefaultDoc", "Login.aspx,Default.aspx");
objVirtualDir.SetInfo();
endif;
catch
// Show an error.
endcatch;
end;
0 Kudos