How to find relative path to C:\Inetpub\AdminScripts\ADSUTIL.VBS?

Mike Atlas picture Mike Atlas · Aug 11, 2009 · Viewed 25.8k times · Source

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?

Answer

JShumaker picture JShumaker · Aug 13, 2009

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