1

従来の ASP Web サイトのインストーラーを作成しました。「ルート」(既定の Web サイト) に Web サイトをインストールできました。しかし、既存の「デモ」サイトの例として、「ルート」ではなく「サイト」の下にウェブサイトをインストールしたいと思います。

何か案が?キーは次のとおりだと思います。

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

必要な場合に備えて、Web サイトを 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;
4

1 に答える 1

0

私は COM オートメーション オブジェクトの専門家ではありませんが、'Sites\' をパラメーターとして渡すのはどうでしょうか。

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

WebRoot.Create でサブディレクトリを作成することは可能ですか? 試す価値はあると思います:)

または、「サイト」を渡す 2 番目のアイデア:

WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Sites');
于 2013-10-04T05:17:32.563 に答える