From: Helge Kruse on
Hello,

I have hundred of VBScripts and JScript scripts calling one WSC. The
calling scripts are started with CScript or WScript as required in the
current environment.

The WSC starts helper VBScripts using shell.Run("scriptname.vbs"). Until
WSH 5.6 these Scripts have been started with the same scripting host,
that has been used from the outer scripts. Starting with WSH 5.7 the
shell.Run() behaves different. It always use WScript as a host.

I can not change the outer VBScripts for several reason, so I can't add
a property to the WSC to pass the calling WScript object. Therefore I
need to detect the host of the calling script inside the WSC. Dependent
on the type of the host I could this information in this way

if (WScripHosted)
shell.Run("wscript scriptname.vbs")
else
shell.Run("cscript scriptname.vbs")

instead of

shell.Run("scriptname.vbs")

How do I detect the scripting host?

Alternatively it would be nice, if there is a way to fix the behavior of
shell.Run.

I've also seen that defining the scripting host with
"wscript //H:host"
does not affect the host that is used when shell.Run is performed in the
WSC. It may be related to the changed location, where the //H:host
information is stored since WSH 5.7

Helge
From: Todd Vargo on
Helge Kruse wrote:
> Hello,
>
> I have hundred of VBScripts and JScript scripts calling one WSC. The
> calling scripts are started with CScript or WScript as required in the
> current environment.
>
> The WSC starts helper VBScripts using shell.Run("scriptname.vbs"). Until
> WSH 5.6 these Scripts have been started with the same scripting host, that
> has been used from the outer scripts. Starting with WSH 5.7 the
> shell.Run() behaves different. It always use WScript as a host.
>
> I can not change the outer VBScripts for several reason, so I can't add a
> property to the WSC to pass the calling WScript object. Therefore I need
> to detect the host of the calling script inside the WSC. Dependent on the
> type of the host I could this information in this way
>
> if (WScripHosted)
> shell.Run("wscript scriptname.vbs")
> else
> shell.Run("cscript scriptname.vbs")
>
> instead of
>
> shell.Run("scriptname.vbs")
>
> How do I detect the scripting host?

If Lcase(Right(WScript.FullName, 11)) = "cscript.exe" then
Wscript.Echo "Host is CSCRIPT.EXE"
Else
Wscript.Echo "Host is NOT CSCRIPT.EXE"
End If


>
> Alternatively it would be nice, if there is a way to fix the behavior of
> shell.Run.

I don't believe 5.7 operates any differently from 5.6.


>
> I've also seen that defining the scripting host with
> "wscript //H:host"
> does not affect the host that is used when shell.Run is performed in the
> WSC. It may be related to the changed location, where the //H:host
> information is stored since WSH 5.7

Taking a guess, you are trying to assign the default host from within a
running script to launch your help scripts. I don't think changing the
default host will affect the currently running script, or necessary, since
you can use WScript.FullName to detect which host is running.

--
Todd Vargo

(Post questions to group only. Remove "z" to email personal messages)


From: Helge Kruse on
Am 26.07.2010 02:54, schrieb Todd Vargo:
>> How do I detect the scripting host?
>
> If Lcase(Right(WScript.FullName, 11)) = "cscript.exe" then
> Wscript.Echo "Host is CSCRIPT.EXE"
> Else
> Wscript.Echo "Host is NOT CSCRIPT.EXE"
> End If
In a VBScript you have a WScript object. But it's not available in a COM
server (WSC).

> I don't believe 5.7 operates any differently from 5.6.
The difference is that on the PCs where 5.7 is installed, a lot of
message boxes pop when WScript.Echo is used -- independent of any believing.

>> I've also seen that defining the scripting host with
>> "wscript //H:host"
>> does not affect the host that is used when shell.Run is performed in
>> the WSC. It may be related to the changed location, where the //H:host
>> information is stored since WSH 5.7
>
> Taking a guess, you are trying to assign the default host from within a
> running script to launch your help scripts.
No. There's no assignment. I just use it. All I need is the same
behavior in outer scripts, WSC and helper scripts.

> I don't think changing the
> default host will affect the currently running script, or necessary,
> since you can use WScript.FullName to detect which host is running.
I can't, see above.


From: Todd Vargo on
Helge Kruse wrote:
> Am 26.07.2010 02:54, schrieb Todd Vargo:
>>> How do I detect the scripting host?
>>
>> If Lcase(Right(WScript.FullName, 11)) = "cscript.exe" then
>> Wscript.Echo "Host is CSCRIPT.EXE"
>> Else
>> Wscript.Echo "Host is NOT CSCRIPT.EXE"
>> End If
> In a VBScript you have a WScript object. But it's not available in a COM
> server (WSC).

Sorry, I reread your previous post and see you do not want to change the
outer scripts. Unfortunatly, you may have to anyway.

>
>> I don't believe 5.7 operates any differently from 5.6.
> The difference is that on the PCs where 5.7 is installed, a lot of message
> boxes pop when WScript.Echo is used -- independent of any believing.
>
>>> I've also seen that defining the scripting host with
>>> "wscript //H:host"
>>> does not affect the host that is used when shell.Run is performed in
>>> the WSC. It may be related to the changed location, where the //H:host
>>> information is stored since WSH 5.7
>>
>> Taking a guess, you are trying to assign the default host from within a
>> running script to launch your help scripts.
> No. There's no assignment. I just use it. All I need is the same behavior
> in outer scripts, WSC and helper scripts.

Please provide a simple example of an outer script, WSC and a helper script.

--
Todd Vargo

(Post questions to group only. Remove "z" to email personal messages)