Is there a way to determine if an external vbscript was called from an
HTA?

Re: Determine if a script was run from an HTA by McKirahan

McKirahan
Fri Feb 17 11:58:26 CST 2006

"jtokach" <jtokach@ptd.net> wrote in message
news:1140198645.513431.209760@g14g2000cwa.googlegroups.com...
> Is there a way to determine if an external vbscript was called from an
> HTA?
>

You could set a "Volatile" Environment variable and test it.

Here's an HTA that sets, gets, and deletes one.

<html>
<head>
<title>volatile.hta</title>
<script type="text/vbscript">
Option Explicit
'*
'* Declare Constants
'*
Const cHTA = "volatile.hta"
'*
'* Set Parameter
'*
document.write cHTA
document.write "<br><br> setENV('Hello=World')"
Call setENV("Hello=World")
'*
'* Get Parameter
'*
document.write "<br><br> getENV('Hello')"
document.write "<br><br> Hello = " & getENV("Hello")
'*
'* Del Parameter
'*
document.write "<br><br> delENV('Hello')"
Call delENV("Hello")

Function delENV(ENV)
'*
'* Get Environment Variable
'*
Dim objWSS
Set objWSS = CreateObject("WScript.Shell")
Dim objENV
Set objENV = objWSS.Environment("Volatile")
objENV(ENV) = ""
Set objENV = Nothing
objWSS.RegDelete "HKCU\Volatile Environment\" & ENV
Set objWSS = Nothing
End Function

Function getENV(ENV)
'*
'* Get Environment Variable
'*
Dim objWSS
Set objWSS = CreateObject("WScript.Shell")
Dim objENV
Set objENV = objWSS.Environment("Volatile")
getENV = objENV(ENV)
Set objENV = Nothing
Set objWSS = Nothing
End Function

Sub setENV(ENV)
'*
'* Set Environment Variable
'*
If InStr(ENV,"=") = 0 Then Exit Sub
Dim arrENV
arrENV = Split(ENV,"=")
Dim objWSS
Set objWSS = CreateObject("WScript.Shell")
Dim objENV
Set objENV = objWSS.Environment("Volatile")
objENV(arrENV(0)) = arrENV(1)
Set objENV = Nothing
Set objWSS = Nothing
End Sub
</script>
</head>
<body>
</body>
</html>