Re: Setting environment variables in IIS 6.0 [PERL @INC MANIPULATION]
From: Issac Goldstand (isaac_at_cpan.org)
Date: 05/11/04
- Next message: doug: "Re: Permission denied: 'CreateObject'"
- Previous message: Steinarr.G.: "IISstate."
- In reply to: David Wang [Msft]: "Re: Setting environment variables in IIS 6.0"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 11 May 2004 15:25:23 +0300
I did it as suggested by David. I created a VBS file to add the quoted "
and it worked fine. For the benefit of people searching archives I have
included the sample drsaticly reduced VBS script below - the script will add
a new service to IIS - there are 2 lines which must be manually changed in
the script - each is preceded by '''''''''''''''' and instructions for the
arguments
Thanks, David and Egbert
Issac
"David Wang [Msft]" <someone@online.microsoft.com> wrote in message
news:%23BKTF$zNEHA.2704@TK2MSFTNGP10.phx.gbl...
> Yeah, the UI is attempting to validate what you enter, and it's impossible
> to determine some incorrect formats from correct ones, so the UI errored
on
> the cautious side. It means that some valid commandlines won't be
possible
> from the UI, and one will need to write to the IIS Admin APIs to do what
you
> need.
>
> Now, you tried using IISEXT, but you didn't know that the command shell
uses
> "s to delimit parameters, so it ate up all the "s before IISEXT even ran.
> It's not going to be your friend in this exercise.
>
> Only option I can think of is to write to the IIS Admin APIs using script.
> Even here, JScript and VBScript treat the "-character in special manner --
> you must escape the " inside a string -- i.e.
> JScript "This is \"within quotes\"..." is interpreted as the string:
This
> is "within quotes"...
> VBScript "This is ""within quotes""..." results in: This is "within
> quotes"...
>
> So, you can take code inside of IISEXT.VBS and IISSCHLP.WSC , modify it to
> set a string containing quotes, and you should get what you want.
>
> I know that this isn't easy, but this is mostly because the "-character is
> special in different ways to a lot of programs (perfectly legal sort of
> thing), and you need to make sure you pass it in the right way to the
right
> program.
>
> --
> //David
> IIS
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> //
> "Issac Goldstand" <isaac@cpan.org> wrote in message
> news:%239YCgtyNEHA.3960@TK2MSFTNGP10.phx.gbl...
> You misunderstand my intent:
> The running CGI application needs to see the environment variables in
order
> to function correctly... I have a few copies of an identical CGI
> application that should run differently based on the site. I have
> sepererated the sites into different application pools and set eaach
> application pool to run as a different user. But the CGI needs to examine
a
> particular environment variable to determine where to find its
configuration
> (based on which site is running). My only other option is changing a
> command line parameter, which I can't do, since it includes a:\full\path
and
> "%s" when I try to enter it into the service extensions, it chokes on the
:,
> and when I try to add it via iisext /AddFile, I can't get it to recognize
> the "s (around "%s") [although '"' seems to work, I keep getting 404.2
> errors, so apparantly it doesn't match].
>
> So far my only workaround seems to be to enable all non-defined CGI
> scripts... That can't be the best way to do it...
>
>
> "Egbert Nierop (MVP for IIS)" <egbert_nierop@nospam.invalid> wrote in
> message news:uCELbpvNEHA.640@TK2MSFTNGP12.phx.gbl...
> > "Issac Goldstand" <isaac@cpan.org> wrote in message
> > news:up3PuTrNEHA.3988@TK2MSFTNGP09.phx.gbl...
> > > Is there any way to set environment variables for CGI applications in
> IIS
> > > 6.0 *without* changing the default system environment?
> >
> >
> > Not really, these variables, are related to the active worker account.
> > The way to go is to use ServerHeader(s). These variables are set in the
> HTML
> > document/HTTP session.
> >
> > > Thanks,
> > > Issac
> > >
===================== iissample.vbs ==========================
' Provided by Issac Goldstand <isaac@cpan.org>
' Please include this disclaimer if distributing this file
' Based on IIsExt.vbs (c) Microsoft, Corporation - All rights reserved
Option Explicit
On Error Resume Next
' Error codes
Const ERR_OK = 0
Const ERR_GENERAL_FAILURE = 1
'''''''''''''''''''''
' Messages
Const L_CmdLib_ErrorMessage = "Could not create an instance of
the CmdLib object."
Const L_ChkCmdLibReg_ErrorMessage = "Please register the
Microsoft.CmdLib component."
Const L_ScriptHelper_ErrorMessage = "Could not create an instance of
the IIsScriptHelper object."
Const L_ChkScpHelperReg_ErrorMessage = "Please, check if the
Microsoft.IIsScriptHelper is registered."
Const L_WMIConnect_ErrorMessage = "Could not connect to WMI
provider."
Const L_Error_ErrorMessage = "Error &H%1: %2"
Const L_Admin_ErrorMessage = "You cannot run this command
because you are not an"
Const L_Adminp2_ErrorMessage = "administrator on the server you
are trying to configure."
Const L_GetWebSvcObj_ErrorMessage = "Could not get web service object"
Const L_EnApp_ErrorMessage = "Error while configuring
application or extension."
Dim oScriptHelper, oCmdLib
Dim intResult
' Instantiate the CmdLib for output string formatting
Set oCmdLib = CreateObject("Microsoft.CmdLib")
If Err.Number <> 0 Then
WScript.Echo L_CmdLib_ErrorMessage
WScript.Echo L_ChkCmdLibReg_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Set oCmdLib.ScriptingHost = WScript.Application
' Instantiate script helper object
Set oScriptHelper = CreateObject("Microsoft.IIsScriptHelper")
If Err.Number <> 0 Then
WScript.Echo L_ScriptHelper_ErrorMessage
WScript.Echo L_ChkScpHelperReg_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Set oScriptHelper.ScriptHost = WScript
' Check if we are being run with cscript.exe instead of wscript.exe
oScriptHelper.CheckScriptEngine
' Initializes authentication with remote machine
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''
' First argument is webserver (localhost is ".")
' Second argument is username
' Third option is password
intResult = oScriptHelper.InitAuthentication("WEB1", "", "")
If intResult <> 0 Then
WScript.Quit(intResult)
End If
Call Go()
WScript.Quit(intResult)
Function Go ()
Dim WebSvcObj, i
On Error Resume Next
oScriptHelper.WMIConnect
If Err.Number Then
WScript.Echo L_WMIConnect_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number),
Err.Description)
ChDep = Err.Number
Exit Function
End If
Set WebSvcObj = oScriptHelper.ProviderObj.get("IIsWebService='w3svc'")
If Err.Number Then
Select Case Err.Number
Case &H80070005
WScript.Echo L_Admin_ErrorMessage
WScript.Echo L_Adminp2_ErrorMessage
Case Else
WScript.Echo L_GetWebSvcObj_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage,
Array(Hex(Err.Number), Err.Description)
End Select
ChDep = Err.Number
Exit Function
End If
If OPER_ADEFI = intOperation Then
If ((aArgs(1) <> 0) And (aArgs(1) <> 1)) Then
aArgs(1) = 0
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''
' First argument is path to executable
' Second is 1 set to allow, 0 to prohibit
' Third is application ID
' Fourth is 1 to allow deletion, 0 to deny
' Fifth is description
' You may call this multiple times to add multiple extensions
WebSvcObj.AddExtensionFile
"c:\perl\bin\perl.exe -ID:\My\Include\Path ""%s"" %s", "1", "SAMPLE", "1",
"Sample Application"
End If
If Err.Number Then
WScript.Echo L_EnApp_ErrorMessage
WScript.Echo Err.Description
ChDep = Err.Number
Exit Function
End If
End Function
- Next message: doug: "Re: Permission denied: 'CreateObject'"
- Previous message: Steinarr.G.: "IISstate."
- In reply to: David Wang [Msft]: "Re: Setting environment variables in IIS 6.0"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|