Managing VBScript with VBA

To achieve multithreading, I write using VBA to create VBScript code ( VBStr ) and write to a file on the fly, before running these helper scripts asynchronously:

 Dim VBFile As Object Dim VBPath As String VBPath = CurrentProject.Path & "\" & GUID() & ".vbs" Set VBFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(VBPath) VBFile.WriteLine VBStr VBFile.Close Dim Shell As Object Set Shell = CreateObject("Wscript.Shell") Shell.Run """" & VBPath & """" 

However, how to manage these scripts in VBA? I can't seem to find a pen or a link to them. Let's say I want to stop hanging / stalled scripts after 60 seconds - how to do this?

+4
source share
1 answer

Use .Exec instead of .Run. The returned WshScriptExec object has methods / properties for monitoring the state and terminating the process.

+5
source

Source: https://habr.com/ru/post/1489223/


All Articles