To achieve multithreading, I'm writing using VBA to construct VBScript code (VBStr
) and write to file on-the-fly, before launching these helper scripts asynchonously:
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 control these scripts back in VBA? I can't seem to get a handle or reference to them. Say I want to terminate hung/stalled scripts after 60secs - how to do this?