Microsoft KB Archive/261205

{|
 * width="100%"|

How to Use Windows Script Host Scripts as CGI Scripts

 * }

Q261205

-

The information in this article applies to:


 * Microsoft Internet Information Services version 5.0

-

IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information about how to do this, view the &quot;Restoring the Registry&quot; Help topic in Regedit.exe or the &quot;Restoring a Registry Key&quot; Help topic in Regedt32.exe.

SYMPTOMS
When you attempt to call a Visual Basic Script from a Web server in the context of a CGI script, the script may fail to run properly.

CAUSE
This usually occurs because the scripting engine is typically executed in the security context of the IUSR_MachineName account created by IIS when it is installed. However, the Cscript.exe file (the scripting engine) requires the presence of certain registry entries for the user context that it runs under (for anonymous access this is the IUSR_MachineName account). Because an HKEY_CURRENT_USER hive is created for the IUSR_Machine account, IIS loads the HKEY_USERS\.DEFAULT hive in its place. However, the HKEY_USERS\.DEFAULT hive does not contain the necessary keys and entries for the scripting engine.

In these cases, a CGI error message occurs without any additional information. This is the correct behavior for CGI error messages. If you debug the actual HTTP error message, you see this as an HTTP 502 502 &quot;Bad Gateway&quot; (&quot;The server received an invalid response from the server from which it was trying to retrieve information.&quot;) error message.

To configure the IIS computer to allow Visual Basic scripts to be executed as a CGI script, see the &quot;More Information&quot; section of this article.

MORE INFORMATION
The Windows Script Host is installed on all Windows 2000 (IIS 5.0) computers. Use the following steps to enable Visual Basic script support:

 Configure the .vbs extension to map to the Cscript.exe file located in the %SYSTEMROOT%\System32 folder. To do this through the Microsoft Management Console (MMC), the configuration steps for IIS 4.0 are as follows:

 Open the IIS 4.0 Management Console application. Right-click your Web site, and then click Properties. Click the Home Directory tab. In the Application Settings dialog box, select Configuration. On the Application Mappings tab, click Add. On a Windows NT 4.0-based computer, the executable is as follows. (Make sure to use correct path to Cscript.exe). Type .vbs for the extension.</li> Make sure that the Script Engine and Check that files exists check boxes are selected.</li> Save the file by clicking OK. Click Apply, and then click OK twice.</li></ol> </li>  In the Registry Editor, create the following registry keys and entries: "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Script Host" "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Script Host\Settings" Make sure that Everyone has Read access to these two registry keys.

Under the HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Script Host\Settings registry key, add the following: BatchMode: REG_DWORD: 0

DisplayLogo: REG_DWORD: 0

Timeout: REG_DWORD: 0 </li> Add the metabase parameters by performing the following steps.

WARNING: Using Adsutil.vbs incorrectly can cause serious problems that may require you to reinstall Internet Information Server 4.0. Microsoft cannot guarantee that problems resulting from the incorrect use of Adsutil.vbs can be solved. Use Adsutil.vbs at your own risk.

To set the value, do the following:

<ol style="list-style-type: lower-alpha;"> </ol> </li> Open a command window (cmd), and go to the Inetpub\AdminScripts directory. (This location may vary depending on your installation of Internet Information Server).</li> Type the following commands with the following syntax:</li> Copy the .vbs script file to a virtual directory on the server that has execute/script permissions. By default, the Scripts directory has the necessary permissions.</li>  You can test the configuration by creating the following script:

<pre class="CODESAMP">  Option Explicit WScript.Echo WScript.Echo &quot;If you see this, it worked.&quot; Save the above script in the Scripts directory as Test.vbs, and then invoke the script using any browser with the following URL:

<pre class="CODESAMP">  http://server/scripts/test.vbs. </li></ol>

NOTE: Similar limitations apply to all situations where a Cscript.exe script is started from the security context of a local system or a local system impersonating a user. The above changes to the registry should remedy these situations.

Additional query words: Windows 2000 iis 5

Keywords : kbOSWin2000

Issue type : kbprb

Technology : kbiisSearch kbiis500