AW: experience with VBScript on Vista needed

Tiemo Hollmann TB toolbook at kestner.de
Wed Jun 3 02:33:54 EDT 2009


Hi Ken and Jim,
thanks for your advices, very helpful.
Tiemo

> -----Ursprüngliche Nachricht-----
> Von: use-revolution-bounces at lists.runrev.com [mailto:use-revolution-
> bounces at lists.runrev.com] Im Auftrag von Ken Ray
> Gesendet: Dienstag, 2. Juni 2009 23:52
> An: Use Revolution List
> Betreff: Re: experience with VBScript on Vista needed
> 
> 
> Hey, Tiemo...
> 
> > My questions are not going to my code, but to some principles with
> calling
> > the shell wscript.exe
> 
> Are you using Rev 2.9 or later? If so, you don't need to call the shell()
> command for VBScript; you can "do <script> as VBScript".
> 
> > 1.  I tried to catch any error from the get shell() command with "the
> > result", "the syserror", "try -catch", but got never any error back from
> the
> > shell, even if I have a wrong syntax in the VB, where the VB fails, the
> rev
> > doesn't gets noticed. Which is the correct way to catch an error from a
> > VBScript on the shell?
> 
> It should come back from the "shell" command. Here's an (old) example of
> activating an application and trapping the result:
> 
> on VBS_AppActivate pTitle
>   put format("set WshShell = WScript.CreateObject(\"WScript.Shell\")")
> into
> tVBS
>   put tVBS & cr & "WshShell.AppActivate" && quote & pTitle & quote into
> tVBS
>   put "C:\vbs_temp.vbs" into tVBSPath
>   put tVBS into url ("file:" & tVBSPath)
>   set the hideConsoleWindows to true
>   get shell("cscript.exe //nologo" && tVBSPath)
>   put it into tResult
>   if there is a file tVBSPath then
>     send "delete file" && quote & tVBSPath & quote to me in 1 second
>   end if
>   if tResult <> "" then return "Error: " & tResult
> end VBS_AppActivate
> 
> Here's how it would be done in Rev 2.9+:
> 
> on VBS_AppActivate pTitle
>   put format("set WshShell = WScript.CreateObject(\"WScript.Shell\")")
> into
> tVBS
>   put tVBS & cr & "WshShell.AppActivate" && quote & pTitle & quote into
> tVBS
>   put tVBS & cr & "result = Err.number" into tVBS
>   do tVBS as "VBScript"
>   put the result into tResult
>   if there is a file tVBSPath then
>     send "delete file" && quote & tVBSPath & quote to me in 1 second
>   end if
>   if tResult <> "" then return "Error: " & tResult
> end VBS_AppActivate
> 
> 
> > 2. Do I have to return explicity any error from the script back to rev,
> or
> > will they passed to rev anyway? If yes, how and where?
> 
> See above...
> 
> > 4. Are there any experiences of windows installations without the
> scripting
> > host? Perhaps the Home edition? If yes, how to check for that?
> 
> Well, according to my informaton, some form of Windows Script Host has
> been
> included on all versions of Windows since Windows 98. You should check to
> make sure that the VBScript you're calling is supported in the various
> versions of Windows you need to support.
> 
> > 5. If every Vista version should have the windows scripting host, can it
> > somehow be deactivated, so that my updater runs without result? If yes,
> how?
> 
> Not AFAIK.
> 
> > 6. If the user clicks "cancel" while Vista is asking to allow this
> process,
> > how can I get aware of this "cancel" in my rev app? Is there a chance to
> > catch a "cancel" down from Vista level in my rev app?
> 
> I don't know, but I'd assume that the request happens *before* the script
> is
> actually run, so you'd need to find a way to determine if your VBScript
> runs
> or not. One way to do this might be for your Rev app to create a file and
> have the VBScript change its contents or delete it. That way you could
> detect "after" the script has run if the original file was still
> there/unchanged. If so, the VBScript didn't run.
> 
> > 7. Are you aware of any other VBScript gotchas?
> 
> Yes - Some anti-virus software will bring up an alert dialog to the user
> letting them know of a "potential malicious activity" if you try to
> manipulate the file system with VBScript (basically any use of the
> FileSystemObject), so that may make #6 above even more difficult.
> 
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list