running WSF
Richard Gaskin
ambassador at fourthworld.com
Wed May 14 02:46:01 EDT 2003
Ken Ray wrote:
>> Nearly completely ignorant about Windows Scripting Host,
>> after poking around on the 'Net I fpound that I can put this
>> into a .wsf file and use launch to activate a given process
>> (bring it to the front):
>>
>> <package>
>> <job id="vbs">
>> <script language="VBScript">
>> set WshShell = WScript.CreateObject("WScript.Shell
>> WshShell.AppActivate "Calculator"
>> </script>
>> </job>
>> </package>
>>
>> Is there any way I could run that directly, such as with the
>> shell function? I've tried setting the shellcommand to
>> wscript.exe to no avail.
>
> First of all, you need to just have two lines of your code in a .vbs
> file, and then use shell() to run the file as you might with any other
> file. So I created a doc on my desktop called "test.vbs" with this code
> in it:
>
> set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.AppActivate "Calculator"
>
> (BTW: Note that you didn't have closing quote and paren on the 'set
> WshShell' line in your code below.)
>
> Then, from MC, I have this:
>
> on mouseUp
> set the hideConsoleWindows to true
> get shell("cd C:\Documents and Settings\Ken Ray\Desktop & start
> test.vbs")
> end mouseUp
>
> .. and voila!
>
> Keep in mind that WSH isn't supported on older Windows versions, and you
> need to know the name of the app you want to activate using the code
> above, but it *does* work!
I haven't tested the lighter VBS version, but the WSF seems to work great as
far back as Win95, or maybe wscript was installed by some app later -- hard
to say, and while MSDN did note some compatibility with Win95 the
description was too sparse to be of much help.
I have it running as an external file; I was hoping to find a way to execute
the script without writing the file.
Tip for anyone who needs to activate an MC window: If you put your stack's
effective title where "Calculator" appears above, as long as that stack is
open it seems to work well.
--
Richard Gaskin
Fourth World Media Corporation
Developer of WebMerge 2.2: Publish any database on any site
___________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
Tel: 323-225-3717 AIM: FourthWorldInc
More information about the metacard
mailing list