Reputation: 2936
I have some vbs/vba scripts running from time to time. But I don't want next vbscript to be proceeded while another either vba- or vbscript is running. There is no problem to determine if another vbscript is running and delay execution of current vbscript:
Set objSWbemServices = GetObject ("WinMgmts:Root\Cimv2")
Set colProcess = objSWbemServices.ExecQuery _
("Select * From Win32_Process where name = 'wscript.exe'")
Do While colProcess.Count > 1
WScript.Sleep 10000
Set colProcess = objSWbemServices.ExecQuery _
("Select * From Win32_Process where name = 'wscript.exe'")
Loop
But I can't find a particular process of vba script running in Excel. How one can check in vbscript if vba script is running?
Upvotes: 0
Views: 1982
Reputation: 867
I don't think that is possible, as far as I know, VBA in Excel is not executed as a separate process in the Windows operating system.
However, it is possible to find the WSH/WScript/CScript process for your vbscript by matching the CommandLine
column from Win32_Process
with the specific script name.
Upvotes: 1