无法获取 IIS 网站列表以允许用户选择在 Inno Script 安装中使用的安装位置,请提供帮助
我目前正在尝试创建一个 Inno 脚本安装程序,它从用户的 IIS 安装中请求“网站”列表,以便用户可以从组合框列表中选择适当的网站,并且该列表可用于在正确的网站位置。
我需要生成 IIS 网站列表,例如填充组合框的“默认网站”
到目前为止,我只能使用以下代码基于硬编码组合框选择将虚拟目录安装到某个位置。
[Run]
Filename: {sys}\iisvdir.vbs; Parameters: "/create ""{code:GetWebSite}"" MyApp ""{app}\Website"""; Flags: skipifdoesntexist waituntilterminated shellexec; StatusMsg: Creating IIS Virtual Directory
[Code]
var
WebsitePage: TWizardPage;
ComboBox: TNewComboBox;
procedure InitializeWizard;
begin
WebsitePage := CreateCustomPage(wpSelectComponents, 'Select which website you wish to install to',
'Which website should I install to?');
ComboBox := TNewComboBox.Create(WebsitePage);
ComboBox.Width := WebsitePage.SurfaceWidth;
ComboBox.Parent := WebsitePage.Surface;
ComboBox.Style := csDropDownList;
ComboBox.Items.Add('Default Web Site');
ComboBox.Items.Add('Website 1');
ComboBox.ItemIndex := 0;
end;
function GetWebSite(Param: String): String;
begin
{ Return the selected Website }
Result := ComboBox.Text;
end;
我现在需要做的就是动态设置用户在 IIS 中拥有的可用网站中的项目...
感谢您的帮助!
I am currently attempting to create an Inno script installer which requests a list of "Web sites" from a user's IIS installation so that the user can select the appropriate website from a combo box list and this list can be used to create a virtual directory in the correct Website location.
I need to Generate a list of IIS websites e.g. "Default Web Site" populating a combo box
So far I have only been able to achieve installing the virtual directory to a location based on a hard-coded combobox selection with the following code.
[Run]
Filename: {sys}\iisvdir.vbs; Parameters: "/create ""{code:GetWebSite}"" MyApp ""{app}\Website"""; Flags: skipifdoesntexist waituntilterminated shellexec; StatusMsg: Creating IIS Virtual Directory
[Code]
var
WebsitePage: TWizardPage;
ComboBox: TNewComboBox;
procedure InitializeWizard;
begin
WebsitePage := CreateCustomPage(wpSelectComponents, 'Select which website you wish to install to',
'Which website should I install to?');
ComboBox := TNewComboBox.Create(WebsitePage);
ComboBox.Width := WebsitePage.SurfaceWidth;
ComboBox.Parent := WebsitePage.Surface;
ComboBox.Style := csDropDownList;
ComboBox.Items.Add('Default Web Site');
ComboBox.Items.Add('Website 1');
ComboBox.ItemIndex := 0;
end;
function GetWebSite(Param: String): String;
begin
{ Return the selected Website }
Result := ComboBox.Text;
end;
All I need to do now is dynamically set the items from the available Websites that the user has in IIS...
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
事实上,我昨天“解决”了这个问题,但仍然没有找到关于这个主题的任何其他内容,所以我想我们是先驱者;)。我开始了你所做的很长的一行,但我找不到任何有用的文档,所以走了另一条路。虽然我的解决方案有效,但非常混乱。
基本上,我运行一个 VB 脚本,将网站列表输出到一个文本文件,然后将该文本文件读回到 Inno 安装程序中。下面是我当前的代码,非常粗糙,我计划稍后对其进行整理并添加适当的错误处理。
Website.vbs
Innosetup 脚本
Actually I "solved" this yesterday, still haven't found anything else on this subject so I guess we are pioneers ;). I started a long the lines you did but I could not find any useful documentation and so went down another path. Although my solution works it is very messy.
Basically I run a VB script that outputs the list of web sites to a text file and then read that text file back into Inno setup. Below is my current code, which is very rough, I plan to tidy it up and add appropriate error handling later.
Website.vbs
Innosetup script
好消息!!我发现了我们一直在寻找的隐藏的东西,并且您不需要单独的 vb 项目来修复它。
再次继承我的代码:
答案是将 ComboBox.Items.Add 行更改为 .ServerComment,而不是 .Name。
享受吧:)
斯图
Good news!! I found the hidden thing we've both been looking for, and you don't need a separate vb project to fix it.
Heres my code again:
The answer was changing the ComboBox.Items.Add line to .ServerComment, not .Name.
Enjoy :)
Stu
我对你的问题有点进一步,但我仍然没有解决它!我可以得到它在目录中出现的号码,但不能得到名称本身。
这是我到目前为止所拥有的。如果您设法更进一步,请让我知道您做了什么:)
抱歉,如果一两个组合框命名错误。我从我的来源复制了它并尝试将其与你的名字相匹配。它基本上连接到 IIS 并列出 Web 服务器名称。由于某种原因,它们以 ID 的形式出现:(
我最终也不需要第二个函数(你的 getwebsite)
MSDN 提到名称可以被覆盖以显示键,但没有详细说明,我正疯狂地试图找出答案如果这是错误的话,它可能会被覆盖。
http://msdn.microsoft.com/en-us /library/ms525545%28VS.90%29.aspx
I'm a bit further on with your problem, but I still haven't cracked it either! I can get the number it appears in the directory, but not the name itself.
Heres what I have so far. If you manage to take it further, please let me know what you did :)
Sorry if a combobox or two is named wrong. I copied it from my source and tried to match it to your names. It basically connects to IIS and lists the webserver names. For some reason they come out as ID's though :(
I also didn't end up needing a second function (your getwebsite)
MSDN mentions Name can be overridden to display keys but doesn't elaborate and I'm going crazy trying to find out where it could be getting overridden if thats is the error.
http://msdn.microsoft.com/en-us/library/ms525545%28VS.90%29.aspx
我已经更正了 Stu 的代码。
您必须使用 WebServer.ServerComment 而不是 WebServer.Name
I have corrected the code from Stu.
You have to use WebServer.ServerComment instead of WebServer.Name