Inno Setup:如何设置IIS应用程序池的高级设置?

huangapple go评论85阅读模式
英文:

Inno Setup : How to setup advance settings for IIS application pool?

问题

在Inno Setup脚本中如何设置IIS应用程序池的高级设置?我特别想要设置闲置超时属性。
我找不到有关设置IIS或部署网站的有用信息 Inno Setup产品帮助页面

以下是从IIS中捕获的高级属性的屏幕截图:

Inno Setup:如何设置IIS应用程序池的高级设置?

以下是我创建应用程序池的代码片段:

{配置IIS网站}
procedure ConfigureIISWebsite();
begin
  try
  AppPool.Stop();
  // 连接到IIS服务器。
  WebService := IIS.GetObject('IIsWebService', '{#IISServerName}' + '/w3svc');
  // 获取网站。
  WebServer := WebService.GetObject('IIsWebServer', '{#IISServerNumber}');
  WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');
  except
  end;
end;

{配置应用程序池}
function ConfigureAppPool(): Boolean;
begin
   // 将值读入变量
  Result := True;
  ApplicationName := InputAppNamePage.Values[0];
  VirtualDirectory := InputAppNamePage.Values[0];
  IISApplicationPoolName := InputAppNamePage.Values[0];
    // 创建应用程序池。
    try
      AppPool := AppPools.Create('IIsApplicationPool', IISApplicationPoolName);
      AppPool.ManagedPipelineMode := '{#APPPOOL_MANAGED_PIPELINE_MODE}';
      AppPool.ManagedRuntimeVersion :=   '';
      AppPool.SetInfo();
      ConfigureIISWebsite();
    except
      Log('无法创建应用程序池。');
      Result := False;
      Exit;
    end;     
  end;
end;

如果有人能指向我任何有用的资源或代码片段,将不胜感激。

英文:

In Inno setup script how to set advance settings for IIS application pool? I'm specifically looking for setting Idle Time-out property?
I was not able to find and helpful information related to setting up IIS or deploying website Inno Setup product help page

Here's screen capture of advance property from IIS :

Inno Setup:如何设置IIS应用程序池的高级设置?

Following is a snippet of where I create application pool:

{Configure IIS website}
procedure ConfigureIISWebsite();
begin
  try
  AppPool.Stop();
  // Connect to the IIS server. 
  WebService := IIS.GetObject('IIsWebService', '{#IISServerName}' + '/w3svc');
  // Get the website. 
  WebServer := WebService.GetObject('IIsWebServer', '{#IISServerNumber}');
  WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');
  except
  end;
end;

{Configure App pool}
function ConfigureAppPool(): Boolean;
begin
   // Read values into variables
  Result := True;
  ApplicationName := InputAppNamePage.Values[0];
  VirtualDirectory := InputAppNamePage.Values[0];
  IISApplicationPoolName := InputAppNamePage.Values[0];
    // Create the application pool. 
    try
      AppPool := AppPools.Create('IIsApplicationPool', IISApplicationPoolName);
      AppPool.ManagedPipelineMode := '{#APPPOOL_MANAGED_PIPELINE_MODE}';
      AppPool.ManagedRuntimeVersion :=   '';
      AppPool.SetInfo();
      ConfigureIISWebsite();
    except
      Log('Failed to create an application pool.');
      Result := False;
      Exit;
    end;     
  end;
end;

Would appreciate if someone can point me to any helpful resource or code snippet.

答案1

得分: 0

以下是翻译好的内容:

基于来自@MartinPrikryl的建议,以下是适用于我的用例的操作方式:

AppPool.IdleTimeout := '0'; // 0 值表示无限期

在探索过程中,我还通过以下方式实现了相同的效果:

注意:以适当的管理权限运行安装程序。

1) 使用 [Registry] 部分:

    [Registry]
    ; 修改 IIS 应用程序池的空闲超时
    Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\IIS\{IIS 版本}\AppPools\{YourAppPoolName}"; ValueType: dword; ValueName: "IdleTimeout"; ValueData: {以秒为单位的时间}

用适当的值替换以下占位符:

  • {IIS 版本}:您要定位的 IIS 版本(例如,对于 IIS 7,使用 "7.0",对于 IIS 10,使用 "10.0")。
  • {YourAppPoolName}:要修改的 IIS 应用程序池的名称。
  • {以秒为单位的时间}:所需的空闲超时值(例如,30 分钟为 1800 秒)。

2) 使用 [Run] 部分:

   [Run]
   Filename:{sys}\inetsrv\appcmd.exe; Parameters:"set apppool /apppool.name:YourAppPoolName /processModel.idleTimeout:00:30:00"; Flags: runhidden

用适当的值替换以下占位符:

  • YourAppPoolName:要修改的 IIS 应用程序池的名称。
  • 00:30:00:所需的空闲超时值,以秒为单位(例如,30 分钟为 1800 秒)。

希望这对未来的其他人有所帮助。

英文:

Based off suggestion from @MartinPrikryl following is what worked for my use case :

AppPool.IdleTimeout := '0'; // 0 value means infinite

While exploring this I was also able to achieve same by using following ways :

NOTE : Run installer with appropriate administrative privileges.

1) Using [Registry] section :

    [Registry]
    ; Modify Idle Time-out for an IIS application pool
    Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\IIS\{IIS Version}\AppPools\{YourAppPoolName}"; ValueType: dword; ValueName: "IdleTimeout"; ValueData: {time in seconds}

Replace the following placeholders with appropriate values:

  • {IIS Version}: The version of IIS you are targeting (e.g., "7.0" for IIS 7, "10.0" for IIS 10).
  • {YourAppPoolName}: The name of the IIS application pool you want to modify.
  • {time in seconds}: The desired idle timeout value in seconds (e.g., 1800 for 30 minutes).

2) Using [Run] section :

   [Run]
   Filename:{sys}\inetsrv\appcmd.exe; Parameters:"set apppool /apppool.name:YourAppPoolName /processModel.idleTimeout:00:30:00"; Flags: runhidden

Replace the following placeholders with appropriate values:

  • YourAppPoolName: The name of the IIS application pool you want to modify.
  • 00:30:00: The desired idle timeout value in seconds (e.g., 1800 for 30 minutes).

Hope this helps others in future.

huangapple
  • 本文由 发表于 2023年8月4日 20:46:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76836050.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定