Search code examples
iisiis-6metabaseinstallscriptadsutil.vbs

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


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?


Solution

  • 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.