HOWTO: Use Windows Script Host Scripts as CGI ScriptsID: Q221081
|
When attempting to call a Visual Basic Script from a Web server in the context of a CGI script, the script may fail to run properly. The most likely reason for this is that the scripting engine is typically executed in the security context of the IUSR_Machine created by IIS when it is installed.
Unfortunately, the Cscript.exe (the scripting engine) requires the presence of certain registry entries for IUSR_Machine user. Since a HKEY_CURRENT_USER hive is not available for the IUSR_Machine, IIS will load the HKEY_USERS\.DEFAULT hive in its place. However, the HKEY_USERS\.DEFAULT hive does not contain the neccessary keys and entries for the scripting engine.
In these cases, a CGI error will occur, without any additional information. Or if the Cscript.exe file was launched in batch mode, an error will appear indicating it was unable to load the settings for the specified user. This document will show how to configure the IIS machine to allow Visual Basic Scripts to be executed as a CGI script.
This article assumes that the Windows Script Host is installed on the IIS server machine; the default installation option of NT Option Pack will do this.
Use the following steps to enable VBScript support:
C:\WINNT\system32\CSCRIPT.EXE.exe %s %s
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Scripting Host
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Scripting Host\Settings
Verify that Everyone has Read access to these two keys.
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Scripting Host\Settings
BatchMode: REG_DWORD: 0
DisplayLogo: REG_DWORD: 0
Timeout: REG_DWORD: 0
Option Explicit
WScript.Echo "Content-Type: text/html"
WScript.Echo
WScript.Echo "If you see this, it worked."
Save the above script in the /scripts directory as Test.vbs. Now invoke the script using any browser with the following URL:
http://server/scripts/test.vbs.
NOTE: Similar limitations apply to all situation where a Cscript.exe script is launched 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.
Microsoft Internet Informatio Server Online Documentation.
Additional query words:
Keywords :
Version : WINDOWS:1.1,2.0,3.0,4.0,5.0; winnt:4.0
Platform : WINDOWS winnt
Issue type : kbhowto
Last Reviewed: July 16, 1999