如何找到 C:\Inetpub\AdminScripts\ADSUTIL.VBS 的相对路径?

发布于 2024-08-01 18:38:45 字数 1523 浏览 2 评论 0 原文

IIS 6 及更早版本附带一个名为 ADSUTIL.VBS

Adsutil.vbs 是 IIS 管理 使用 Microsoft Visual 的实用程序 基础脚本版 (VBScript) 与活动目录服务 接口(ADSI)来操纵 IIS 配置。 这个脚本应该 使用 CScript 运行,即 与 Windows 脚本宿主一起安装。

换句话说,此工具可让您更改 IIS 元数据库< /a> 从命令行以编程方式设置。

我想从 InstallShield 项目调用此工具,以便对 IIS 进行一些配置更改。 我很好奇重新分发脚本是否合法(源代码中没有合法的措辞)或简单地通过以下方式启动命令:

CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs

并希望脚本存在于磁盘上的该位置。

所以我的问题是 - 即使计算机上的某些其他网站(inetpub 根)位于非系统驱动器上,它是否始终存在于上面的路径中? 似乎所有引用 ADSUTIL 工具的 MSDN 和其他 Microsoft 知识库文章都是通过使用上面的 %SYSTEMDRIVE% 路径来实现的。

我看到至少另一种尝试来处理这个问题通过将 cscript.exe 和 adsutil.vbs 与其 InstallShield 项目一起分发。

也许有注册表项或其他方法来获取 Inetpub\AdminScripts 路径的位置?

也许我应该编写一个 C# 应用程序来更改值我自己的 VBScript 并分发用我自己的小应用程序代替?

IIS 6 and older ships with a utility script called ADSUTIL.VBS:

Adsutil.vbs is an IIS administration
utility that uses Microsoft Visual
Basic Scripting Edition (VBScript)
with Active Directory Service
Interfaces (ADSI) to manipulate the
IIS configuration. This script should
be run using CScript, which is
installed with Windows Script Host.

In other words, this tool lets you change IIS metabase settings programmatically, from the command line.

I would like to call this tool from an InstallShield project in order to make some configuration changes to IIS. I am curious if it either legal to re-distribute the script (there is no legal wording inside the source for it) or to simply launch the command via:

CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs

and hope that the script exists on disk in that location.

So my question is - will it always exist in that path above, even if some other websites (inetpub roots) on the machine are located on a non-system drive? It seems all MSDN and other Microsoft KB articles that refer to the ADSUTIL tool do so by using the %SYSTEMDRIVE% path above.

I see that at least one other attempt to deal with this by distributing both cscript.exe and adsutil.vbs with their InstallShield projects.

Perhaps there is a registry key or other method to obtain the location of the Inetpub\AdminScripts path?

Maybe I should just write a C# application that changes the value or my own VBScript and distribute with my own little app instead?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

兔姬 2024-08-08 18:38:45

我在JShumaker的答案< /a> 来解决问题。 最好的路线似乎是我调用来运行批处理脚本的以下 InstallScript 函数:

prototype SetIISValues();   
function SetIISValues()  
    string szProgram, szCmd;
begin                              
    szProgram = TARGETDIR + "SetIISValues.bat";
    szCmd = "";  
    LaunchAppAndWait (szProgram, szCmd, LAAW_OPTION_WAIT);
end; 

批处理脚本调用此: VBScript

@echo off
cscript.exe SetIISValues.vbs

如下所示:

Option Explicit
Dim IIsObject
Set IIsObject = GetObject("IIS://localhost/w3svc/1")
IIsObject.Put "Name", "Value"
IIsObject.Setinfo

这样做可以减轻在安装过程中使用 ADSUTIL.VBS 的需要 -如果您不需要使用它,则它的(相对)路径是无关紧要的。

I worked in JShumaker's answer to solve the problem. The best route seems to be the following InstallScript function that I call to run a batch script:

prototype SetIISValues();   
function SetIISValues()  
    string szProgram, szCmd;
begin                              
    szProgram = TARGETDIR + "SetIISValues.bat";
    szCmd = "";  
    LaunchAppAndWait (szProgram, szCmd, LAAW_OPTION_WAIT);
end; 

The batch script calls this:

@echo off
cscript.exe SetIISValues.vbs

And the VBScript looks like this:

Option Explicit
Dim IIsObject
Set IIsObject = GetObject("IIS://localhost/w3svc/1")
IIsObject.Put "Name", "Value"
IIsObject.Setinfo

Doing it this way relieves the need to use ADSUTIL.VBS as part of the installation - the (relative) path to it is irrelevant if you don't need to use it.

芸娘子的小脾气 2024-08-08 18:38:45

我最近遇到了类似的问题,决定重新编写一小部分 vbscript,以便在 msi 安装程序中的自定义操作中使用。 可能需要一些时间才能弄清楚 adsutil.vbs 的核心工作原理,但它写得非常好。 例如,我需要将应用程序池切换到经典模式而不是集成模式,并明确将其设置为在 64 位 Windows 上运行时以 32 位模式运行,以精炼形式,这会导致以下结果:

Option Explicit

Dim IIsObject
Set IIsObject = GetObject("IIS://LocalHost/W3SVC/AppPools/TestPool")
IIsObject.Put "ManagedPipelineMode", 1
IIsObject.Setinfo
IIsObject.Put "Enable32BitAppOnWin64", CBool("True")
IIsObject.Setinfo

I ran into a similar issue recently and decided to just rework a small bit of vbscript to use in a custom action in an msi installer. It can take a bit to figure out the core of how adsutil.vbs does things, but it is deently well writen. For example, i needed to switch an application pool to Classic instead of Integrated mode and explicitly set it to run in 32-bit mode when on 64-bit windows, in distilled form this resulted in this:

Option Explicit

Dim IIsObject
Set IIsObject = GetObject("IIS://LocalHost/W3SVC/AppPools/TestPool")
IIsObject.Put "ManagedPipelineMode", 1
IIsObject.Setinfo
IIsObject.Put "Enable32BitAppOnWin64", CBool("True")
IIsObject.Setinfo
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文