Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to wait for a objShell.Exec finish executing a command?

2,145 views
Skip to first unread message

BwiseIT

unread,
Sep 8, 2006, 7:57:04 PM9/8/06
to
I am creating a shell object to zip a file, then delete the source file, but
the objFSO.DeleteFile(objFileName) is executing before the zip is done, and
deleting the file before it can be zip; so i think. I am checking the error
code for anything other than zero, and it looks like the file is getting
zipped but the delete happens so fast i can't be sure where the problem is.

Obviously if i comment the DeleteFile method i see the file get zip. Do i
need to put some sort of Sleep/Wait variable in my script?

B


Fosco

unread,
Sep 8, 2006, 10:30:26 PM9/8/06
to
"BwiseIT"

>Do i need to put some sort of Sleep/Wait variable in my script?

Maybe wait for the file :

set oShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
while not FSO.FileExists("test.zip")
WScript.Sleep 1000 '
Wend
msgbox "done"


' generic .exec sample :
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("calc")' programma principale
' aka tua connessione

'Quando il programma principale termina vengono
' terninati anche i secondari
Set oExec1 = WshShell.Exec("notepad")' programma secondario
Set oExec3 = WshShell.Exec("Clipbrd")' programma secondario
'Set oExec4 >> ecc
WScript.Sleep 1500
WshShell.AppActivate("calculator")
msgbox"Try to close calc"
Do While oExec.Status = 0
WScript.Sleep 10
Loop
''WScript.Echo "status" &" >>>"& oExec.Status &" " &"Closed"

oExec1.Terminate()
'oExec2.Terminate()
oExec3.Terminate()

--
Fosco


0 new messages