views:

3039

answers:

3

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?

+3  A: 

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
JShumaker
I guess I'll take the bait and go that route instead (write my own vbscript and distribute that). I'll post my own answer and credit your suggestion.
Mike Atlas
+1  A: 

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.

Mike Atlas
+1  A: 

Thank you for your posts, works beautifully! I had to use the suggested code to set iis5IsolationModeEnabled = false.

Dim IIsObject Set IIsObject = GetObject("IIS://localhost/w3svc") IIsObject.Put "iis5IsolationModeEnabled", CBool("False") IIsObject.Setinfo

worked perfectly. I was struggling with adsutil.vbs as the original question.

J-Dog