2013-10-03 248 views
1

我爲一個經典的asp網站創建了一個安裝程序。 我設法在我的「根」(默認網站)中安裝網站。 但我想在「網站」下安裝網站,但不是在「根」下安裝網站,例如在現有的「演示」網站上。Inno setup安裝網站不在根

任何想法? 我認爲關鍵是在線路:

WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root'); 

的情況下,我使用的網站添加到IIS「根」的某些代碼需要:

if (IISOptionsPage.Values[1] <> '') then begin 
    IISDefAppPool := IISOptionsPage.Values[1]; 
end else begin 
    IISDefAppPool := ExpandConstant('{#IISDefaultAppPool}'); 
end; 

{ Create the main IIS COM Automation object } 
try 
    IIS := CreateOleObject('IISNamespace'); 
except 
    RaiseException('IIS is not installed?.'#13#13'(Error: ''' + GetExceptionMessage); 
end; 

{ Connect to the IIS server } 

WebSite := IIS.GetObject('IIsWebService', IISServerName + '/w3svc'); 
WebServer := WebSite.GetObject('IIsWebServer', IISServerNumber); 
WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root'); 

WebAppName := ExtractLastDir(ExpandConstant('{app}')); 

{ (Re)create a virtual dir } 

try 
    WebRoot.Delete('IIsWebVirtualDir', WebAppName); 
    WebRoot.SetInfo(); 
except 

end; 

VDir := WebRoot.Create('IIsWebVirtualDir', WebAppName); 
VDir.AccessRead := True; 
VDir.AccessScript := True; 
VDir.AppFriendlyName := WebAppName; 
VDir.AspEnableParentPaths := True; 
VDir.Path := ExpandConstant('{app}'); 

try 
    VDir.AppPoolId := IISDefAppPool; 
except 
    MsgBox('AppPool not set.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok); 
end; 

try 
    VDir.AppCreate(True); 
except 
    MsgBox('App not created.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok); 
end; 

try 
    VDir.SetInfo(); 
except 
    MsgBox('Info no set.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok); 
end; 

回答

0

我不是COM自動化對象的專家,但如何通過「站點」作爲參數:

VDir := WebRoot.Create('IIsWebVirtualDir', 'Sites\' + WebAppName); 

是否有可能在WebRoot.Create中創建子目錄?我認爲這是值得嘗試:)

或第二的想法,通過「站點」中:

WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Sites'); 
+0

或許用斜線將工作:網站/ – Slappy