Login | |
|
 |
RE: Timeout a VBScript? - 12/17/2007 10:08:19 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
Well you could always use a vbscript to call the script that you want to time asyncronously. Then you would have the PID of the script that does all the real work and the parent script could kill it.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Timeout a VBScript? - 12/17/2007 10:14:24 AM
|
|
 |
|
| |
dm_4ever
Posts: 2433
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
Executing a command using WScript.Shell and the Exec method will allow you to capture the PID of that process that is spawned. WMI can also provide a PID.
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Timeout a VBScript? - 12/17/2007 10:19:53 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
You could execute an executeable that you wrote in VB. You could not execute raw code. If you want it all to be self contained in one file, then you have a couple of options. One is a self extracting executeable package that holds both files and extracts them at run time. Another is to have the parent script physically write the child file then run it. VBS does not support threading per se. At least not the way a more developed programming languages does. That sort of thread control simply isn't what vbscript is intended for.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Timeout a VBScript? - 12/17/2007 12:05:18 PM
|
|
 |
|
| |
Fredledingue
Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
|
I don't understand: If the script needs to return a certain number for timeout and another number for complete execution, why it can't be 0 and 42 respectively? Just modify the application monitoring the script so that it interpretates 0 as failure and any other number as success. If that's not possible, launch the vbs through another vbs which will translate any other number into 0 and vice versa, then quit with the right number. Such script takes 3 lines. Note that for beter portability, it's better to avoid wmi...
_____________________________
Fred
|
|
| |
|
|
|
 |
RE: Timeout a VBScript? - 12/18/2007 10:38:41 AM
|
|
 |
|
| |
Fredledingue
Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
|
quote:
yes I understand what you are saying, but it is not feasible to change the application that it integrates with and I want this to remain 1 script. It is more important in fact to maintain this in 1 clean script than to have the timeout feature. You can keep it one script by letting the main script writing then launching the second script, then delete it. Or use hta (vbscript embedded in hta application): With Hta you can launch a sub using SetInterval (sorry I don't remeber the code right now) and if past a certain time the sub close the window (and the script). The advantage with SetInterval is that other subs are still running in the meantime. Hta, for this feature alone is your solution to your problem. quote:
Could you elaborate on why wmi is not portable? I thought all modern windoze had it? hmm,.. yes. "Only modern windoze" would be more exact. (I'm on w98se ) Beside that are you sure WMI works exactely the same from 2000 to Vista? That's just a thought. I'm no expert.
_____________________________
Fred
|
|
| |
|
|
|
 |
RE: Timeout a VBScript? - 12/19/2007 10:44:22 AM
|
|
 |
|
| |
Fredledingue
Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
|
humbletech99, I'm pretty sure you can run an hta invisible, or at least minimized. HTH
_____________________________
Fred
|
|
| |
|
|
|
|
|