* http://technet.microsoft.com/en-us/library/ee692837.aspx * http://support.microsoft.com/kb/278411/en-us * http://www.experts-exchange.com/Programming/Languages/C/Q_27717068.html * http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/ * http://www.pg-forum.de/programmierung/4216-dump-ber-windowsscriptinghost.html Clear Local lcLogFile m.lcLogFile = "C:\Temp\Log.txt" Local lcCommand m.lcCommand = [%comspec% /c ] + ; [""C:\Program files\PostgreSQL\9.2\bin\pg_dump.exe" ] + ; [--verbose ] + ; [--file="C:\Temp\efiscal_20121001_e9999.backup" ] + ; [--format=c --compress=9 --host localhost --port 5432 ] + ; [--username postgres --no-password --schema=e9999 efiscal"] + ; [ 1>] + m.lcLogFile + [ 2>&1] Local loWSH As "WScript.Shell" m.loWSH = Createobject("WScript.Shell") Local lnReturn, lnAttempts, llFinished, lnHandle m.lnAttempts = 0 m.lnReturn = m.loWSH.Run(m.lcCommand,0,.F.) If m.lnReturn==0 && No error Do While Not m.llFinished If File(m.lcLogFile) * The file can't be opened for read/write while * command is still in progress... m.lnHandle = Fopen(m.lcLogFile,12) If m.lnHandle >= 0 m.llFinished = .T. Fclose(m.lnHandle) Endif ? Filetostr(m.lcLogFile) Else apiSleep(10) && Wait... m.lnAttempts = m.lnAttempts + 1 If m.lnAttempts==10 m.llFinished = .T. m.lnReturn = -1 Endif Endif DoEvents Enddo If File(m.lcLogFile) Delete File (m.lcLogFile) && Recycle Endif Endif If Not m.lnReturn==0 && An error occurred ? "Error ", m.lnReturn Endif m.loWSH = Null Return Function apiSleep Lparameters nMiliseconds Declare Integer Sleep In Win32API As apiSleep ; Integer nMiliseconds Return apiSleep(m.nMiliseconds) Endfunc