How to programmatically wait for a shell command to complete to shut down?

I send letters in such a program:

Call Shell(smtpPath, emailInput...) 

This works fine if only I call the function twice, the function runs for the first time, calls the shell command, then the function runs again and again calls the shell command, but the first shell command is not completed, so there is an error because the second shell command is trying to use one same smtp file as the first (which is still in use).

How to make a function wait until a shell command completes?

Addendum: Or is there a way I can see if the file is being used, and if so, sleep mode, then try again?

+6
source share
1 answer

You can use WScript.Shell , and run the method:

 Set objShell = CreateObject("WScript.Shell") result = objShell.Run(smtpPath & " " & emailInput, 0, true) 
+5
source

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


All Articles