Hi There,
i am using the shell function to execute a program that will zip 10 big data files. so my code is something like this:

for n = 1 to 10
t=shell(zip data(n)) 'not the real code
' somewhere here, i need a code to test if the data(n) is already finished before going to the next loop

next n

can somebody show me a code to do this?. thanks in advance.

newvbguy

Recommended Answers

All 4 Replies

I'm guessing zip is the external EXE file, and data(n) is the filename?
There are a ton of different method's to handle this kind of ideal. The easiest way to go about this, is to use a VbScript. There are others, with shellexecute, waitforsingleobject API's and others... but the easiest (and probably most effecient based on code readability) is as such:

dim WSH
set WSH = createobject("WScript.Shell")
WSH.Run "zip " & data(n), 0, 1

The WSH.Run method executes an external program, the first integer value, defines the visibility state of the window... 0 is hidden, so it doesn't show the DOS window, or ZIP program window to the screen. The trailing integer, set to 1, tells WSH's Run Method To Block (not return to program code execution) UNTIL the command or program being run by WSH's run method returns. It doesn't matter how it returns, either. Error, Success, or something in between. As long as it returns (the program finish's running), then it will move on. Not until then, however. Let me know how it turns for you.

I'm guessing zip is the external EXE file, and data(n) is the filename?
There are a ton of different method's to handle this kind of ideal. The easiest way to go about this, is to use a VbScript. There are others, with shellexecute, waitforsingleobject API's and others... but the easiest (and probably most effecient based on code readability) is as such:

dim WSH
set WSH = createobject("WScript.Shell")
WSH.Run "zip " & data(n), 0, 1

The WSH.Run method executes an external program, the first integer value, defines the visibility state of the window... 0 is hidden, so it doesn't show the DOS window, or ZIP program window to the screen. The trailing integer, set to 1, tells WSH's Run Method To Block (not return to program code execution) UNTIL the command or program being run by WSH's run method returns. It doesn't matter how it returns, either. Error, Success, or something in between. As long as it returns (the program finish's running), then it will move on. Not until then, however. Let me know how it turns for you.

It make sense. For sure I will let you know if I have the chance to try. Thanks again.

Newvbguy

It make sense. For sure I will let you know if I have the chance to try. Thanks again.

Newvbguy

Hi Comatose,
yeah it works ok. thanks

Newvbguy

I'm guessing zip is the external EXE file, and data(n) is the filename?
There are a ton of different method's to handle this kind of ideal. The easiest way to go about this, is to use a VbScript. There are others, with shellexecute, waitforsingleobject API's and others... but the easiest (and probably most effecient based on code readability) is as such:

dim WSH
set WSH = createobject("WScript.Shell")
WSH.Run "zip " & data(n), 0, 1

The WSH.Run method executes an external program, the first integer value, defines the visibility state of the window... 0 is hidden, so it doesn't show the DOS window, or ZIP program window to the screen. The trailing integer, set to 1, tells WSH's Run Method To Block (not return to program code execution) UNTIL the command or program being run by WSH's run method returns. It doesn't matter how it returns, either. Error, Success, or something in between. As long as it returns (the program finish's running), then it will move on. Not until then, however. Let me know how it turns for you.

Thank you! Six google searches over six months and this finally does exactly what I want. Should add a set WSH = nothing at the end.
Thank You again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.