Search code examples
iisnsisvirtual-directory

NsisIIS plugin fails & crashes when performing delete of Virtual Directory


I am trying to get it work for about few days, but still no luck.

OS: Win7 SP2 Ent x64 and W2k8 R2 SP1 Datacenter x64.

I have googled and only real suggestion is to triple-check input params for DeleteVDir function. I have done it for countless times, but no matter what - the plugin crashes and therefore installer, too.

So -

Could someone explain in steps ( formatted for dummies ) - what I need to check and excatly what params I need to input and what system state I need to have to suuccessfuly delete the virtual directory.

Currently I have a call like this:

DetailPrint "Deleting Virtual Directory..."
NsisIIS::DeleteVDir /NOUNLOAD "name_of_virtual_directory" "physical_path_of_virtual_directory"
Pop $0

Solution

  • As far as I can tell, NsisIIS::DeleteVDir only takes a single parameter, not two parameters (/NOUNLOAD does not count as a parameter)

    Another possible problem is that this string is limited to 100 characters. If your name is longer you should file a bug report here. (From a quick look at the code, it seems like it is leaking a lot of memory, you might want to file a bug about that as well)

    It is also possible to call the COM interface with the system plugin, the code might look something like this:

    !include LogicLib.nsh
    !define IID_IADsContainer {001677d0-fd16-11ce-abc4-02608c9e7553}
    
    StrCpy $9 "NameOfItemToDelete" ;Edit this!
    System::Call 'ActiveDS::ADsGetObject(w "IIS://localhost/w3svc/1/Root", g "${IID_IADsContainer}", *i.r1)i.r0'
    ${If} $0 = 0
        System::Call 'OleAut32::SysAllocString(w "IIsWebVirtualDir")i.r2'
        System::Call 'OleAut32::SysAllocString(w "$9")i.r3'
        ${If} $2 <> 0
        ${AndIf} $3 <> 0
            System::Call '$1->15(ir2,ir3)i.r0' ;IADsContainer::Delete
            ;If $0 is 0 then it succeeded, otherwise it failed
            System::Call 'OleAut32::SysFreeString(ir2)'
            System::Call 'OleAut32::SysFreeString(ir3)'
        ${EndIf}
        System::Call '$1->2()' ;Release
    ${EndIf}
    

    (Note: I did not test this code since I don't have a IIS setup to test on)