
trwhtet1.5524935989653728E12 asked a question.
Deleting the existting IIS Virtual Directory
Hi.
Is there any ways that the MSI can delete the IIS Virtual Diectory (or web application) under the Default Web Site, before installing a feature.
Thanks
Thurein
I don't know of a way to do it through installshield.
I used a custom action.
function DeleteVirtualDir(hMSI, szDeleteVR)
OBJECT objIIS_Root, objIIS_Sub;
begin
set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
set objIIS_Sub = CoGetObject("IIS://localhost/W3SVC/1/Root/" + szDeleteVR, "");
if (IsObject(objIIS_Sub)) then
objIIS_Root.Delete("IISWebVirtualDir", szDeleteVR);
SprintfMsiLog ( "DeleteVirtualDir deleted virtual directory: %s" , szDeleteVR);
else
SprintfMsiLog ( "DeleteVirtualDir could not delete virtual directory: %s" , szDeleteVR);
endif;
end;
hope this helps.
Vijay
set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
if (IsObject(objIIS_Root)) then
\\do delete
but the objIIS_Root object got empty all the time so it won't pass the if statement and the delete logic will not be executed. I have tested the above code in both IIS 6 and 7. Pls advice what I am doing wrong.
Thanks Thurein
Post your full code example.
function MyFunction(hMSI)
OBJECT objIIS_Root, objIIS_Sub;
begin
set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
set objIIS_Sub = CoGetObject("IIS://localhost/W3SVC/1/Root/MyVitualDir" , "");
if (IsObject(objIIS_Sub)) then
objIIS_Root.Delete("IISWebVirtualDir", "MyVitualDir");
SprintfMsiLog ( "DeleteVirtualDir deleted virtual directory: &37;s" , "MyVitualDir");
else
SprintfMsiLog ( "DeleteVirtualDir could not delete virtual directory: %s" , "MyVitualDir");
endif;
end;
Thanks
Is the action you have created, deferred in system context?
On operating systems with UAC.
It needs to be deferred in system context to remove the iis. So you might aswell try this before the IIS website are created again in the execute part of the msi installation.
I have set the "In-Script Execution" to "Deffered Execution in System Context" and "Install Exec Sequence" to "After InstallInitialize" but it is still going through the else statement. Any idea ?
Thanks
Thanks