Re: VBScript calls itself
- From: "James Whitlow" <jwhitlow@xxxxxxxxxx>
- Date: 1 Jul 2005 06:59:02 -0500
"shadowHead" <Alpamayo2030@xxxxxxxxx> wrote in message
news:1120095281.980644.48880@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I have a small vbs script that creates an InternetExplorer object and
> runs some stuff but from time to time IE kills over. I have an event
> handler for IE_onQuit but I am wondering I may need to put in there to
> acomplish the following.
>
> When IE dies, my script dies because the object is gone, I would like
> my script to instantiate itself and basically start over by itself.
>
> I had some test code on self instantiation but it is kinda out of
> control, it runs wild replicating 100's of cmd windows. Here is the
> code:
> Dim WshShell, oExec
> Set WshShell = CreateObject("WScript.Shell")
>
> w = WScript.ScriptFullName
> w = Chr(34) & w & Chr(34)
> w = "cmd /k " & w
> WshShell.Run(w)
> WScript.Sleep 10000
>
> How would I get my script to start over ?
This is not exactly the answer you are probably looking for, but one of
the things I do in my scripts that use IE for output is to test the variable
type before writing to my IE window, especially in loops. You can use
something like:
If TypeName(IE) = "IWebBrowser2" Then {some code}
If the IE window you instantiated is still present, it will have a
TypeName of 'IWebBrowser2', once it is closed, the TypeName become "Object".
I generally put a line like this in my loop that write to IE:
If TypeName(IE) = "Object" Then WScript.Quit
...but my needs are different than yours. I do this to let the user end
the script by closing the IE windows.
.
- Prev by Date: Shutdown from a VBS file?
- Next by Date: Re: Shutdown from a VBS file?
- Previous by thread: Shutdown from a VBS file?
- Next by thread: Run script after screensaver
- Index(es):
Relevant Pages
|
Loading