I developed and implemented this function in VBScript.
Most of the answers are given in my articles that link to Mark, but just for clarification:
in what order will Class_Terminate be called?
Terminators are usually called immediately when the last reference to the object is called. However, because of circular links and other issues, it is usually a very bad idea to rely on a determinate termination order.
A restless phrase suggests in the order (and not the reverse order!) Of creation, but is it guaranteed?
As I already noted in my articles, unused objects stop when the engine is turned off. As an implementation detail, the completion queue is executed in the order in which the objects were created. However, this is an undocumented implementation detail that you cannot rely on.
Is there an object type? for example, if I have classes embedded in .VBS mixed with other COM objects such as Scripting.FileSystemObject.
He can. There may be circular links among those objects that break down at unpredictable times.
I think of objects in the global scope when the program exits - it is different from objects, for example. function?
I do not understand the question. Can you clarify?
Does it depend on whether the output is normal, by exception or using WScript.Quit? (In the latter case, it seems that Class_Terminate still calls any incomplete objects before exiting, however this may cause an error message).
It may matter, yes. VBScript does not guarantee that terminators will always work. The host that owns the engine can terminate its process in a “failed” way, for example, without guaranteeing a clean shutdown of the engine. (In the event of a catastrophic failure, this is sometimes desirable, if you don’t know what’s wrong, sometimes running the completion code makes the problem worse, not better.)
Windows Script The host is trying to completely disable the engine when calling Quit.
When is a WScript object destroyed?
When the Windows Script Host process termination logic is executed.
Is there a script host? (wscript.exe vs cscript.exe compared to any web host engine)
Yes, that can make a difference.
Is the JScript object destruction model different from VBScript?
Yes very.
JScript "Classic" from the period when I worked on it (until 2001) uses a non-deterministic marking and markup garbage collector that processes circular links among Script objects, but DOES NOT process circular links between Script and browser objects. Later versions of JScript "Classic" have a modified garbage collector that handles circular references between Script and browser objects (although it does not necessarily detect circular values associated with JScript objects and third-party ActiveX objects.)
IE 9 JScript has a completely rewritten garbage collector that uses very different technologies; I chatted a bit with his designer, but I do not have enough technical knowledge to discuss its characteristics at any depth.
JScript.NET, of course, uses the CLR garbage collector.
May I ask why you care about all this?
Also note that I have not watched this code for more than ten years; take it all with an appropriate level of skepticism. My memory may be malfunctioning.