Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vfp6 does not wait for dos exe to finish executing

Status
Not open for further replies.

codetyko

Programmer
May 26, 2001
73
MY
I develop in VFP6 and still uses the dos based pkzip utility to back up my files. The backup procedure has two options, either to a: drive or a predetermined hard disk location. I used shellexecute to run the command and the required parameters and used the last parameter as "0" to hide the dos screen. However, If the user chooses drive a, I have to show the dos screen in order to indicate the progress of the compression process. If I chose to hide the dos screen, my next line of code will be executed immediately (in this case, a message box saying backup is finished!) while the backup process is still in session. The question is, how do you ensure (through code) that the next command line be executed only after the dos program is finished and while doing so, is it possible to include an avi or progress bar to indicate something is going on? Another thing is, is it possible to "capture" the dos command output and relay it through a vfp form or wait window message?
 
codetyko

If you use the WinAPI call CreateProcess(), you can put the VFP application into a wait state until such time as the external process has finished.

As VFP has no means of determining the progress of the external process, your best option would be to play an .avi file such as filemove.avi or filecopy.avi which you may already have on your system.

thread184-86083 may help or do a keyword search on CreateProcess()

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
codetyko,

I agree with Chris's suggestion. However, for a simpler solution, you could use the Windows Scripting Host. This has a Run method which can be synchronous, that is, it will suspend your program while the DOS command is running:

oWsh = CREATEOBJECT("wscript.shell")
oWsh.Run("pkzip.exe",1,.T.)

For the first parameter to Run method, pass the full path and file name of Pkzip, including the command-line parameters. The second param is the window state. Set the third param .T. to get synchronous execution.

Unfortunately, this won't allow you to display a progress bar. For that, you will have to use Chris's suggestion.

Mike


Mike Lewis
Edinburgh, Scotland
 
Hi

*********************************************
lcBackUp = GETDIR("BackUps","or Backup Drive")
** If CANCELED EXIT .. ETC.. CHECKING CODE..
lcBackUp = "CABARC -r -p N " + ;
lcBackUp+ "myBack.CAB"+SPACE(1)+"DataDir\*.*"
loShell = CREATEOBJECT("wscript.shell")
lnSuccess = loShell.Run(lcBackUp,1,.t.)
*********************************************

Same way for PkZip if A drive
lcBackUp = GETDIR("BackUps","or Backup Drive")
lcBackUp = "PKZIP -rP&f "+ lcBackUp+ ;
"myBack "+"DataDir\*.*"
loShell = CREATEOBJECT("wscript.shell")
lnSuccess = loShell.Run(lcBackUp,1,.t.)
*********************************************

:)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top