1.

Solve : How to get status of an executed batch file?

Answer»

Hi Folks,

Iam calling a batch file from an application developed in Visual Basic. I LIKE to view the status of that batch file in the VB Application in a progress bar.

here the problem is "How to get the status of that batch file from that application"

Please give me a solutions for this..


I think we need more information to answer this.

There are a couple of ways that I can think of to give status in a batch file. The easiest is usually with screen output. Depending on what the batch file is doing, you can output status messages as it processes. If you want to do it from within a VB progress bar, you can probably have the batch file output status updates to a file, and have the VB application read the file to obtain updates. For example:
Code: [Select]...
if {%CopyDone%}=={1} echo CopyDone >>BatchStatus.log
...Then have the VB look for "CopyDone" in the BatchStatus.log and update the progress bar accordingly.

If that is not what you are looking for, please post more details to your delima.Hi Gary,

Actually iam download files from ftp server using 'get' command. Since i need to download more no. of files, i have written a batch file and specified the input and output file in it. i will specify the files to be downloaded in the batch file.

Then iam calling the batch file from an interface developed in VB. I had a progress bar in the interface which should display the status of file download from ftp.(ie. the status of that batch file). is it possible to return the status of the batchfile to the calling function in VB. so that i can increment the value of progress bar each time the batch file completes.?

in your example, my understanding the DOS command need to be specified within the IF statement. once the command gets over result will be written into a log file. but i tried as follows..it doesn't gave me any result.

if {%Copy D:\abc\*.* D:\%}=={1} echo Done >>BatchStatus.log

is my understanding is right?

is ther any solution to get the result fromthe batch file to the calling application.

Are you wanting to return status of each file is it is being FTP'd down (each file has it's own status)? Or the progress of the list of files being FTP'd down (reaches 100% when the last GET completes)?it will be helpful for us if u give the code to get status of list of files downloading(2nd case u mentioned) and first one too

Actually we planned to display the status of files downloading from ftp server in the front end (VB). is it possible?

below is the command we use for ftp to download 5 files

ftp
userid:
pwd:
get
get
get
get
get

here how and where to use ur code to retrieve the status of above mentioned. and this status have to be displayed in the progress bar of VB application.


Here is an idea:
If you could somehow get the window handle from the DOS window then you could use the window title to communicate a string to the VB APP by setting the window title in the FTP script and poll the title string lets say every second by the VB script.
The FTP script could set the window title according to the progress using ! to escape to the shell.

Code: [Select]ftp <servername>
userid:
pwd:
!title 0% done
get <input file> <output file>
!title 25% done
get <input file> <output file>
!title 50% done
get <input file> <output file>
!title 75% done
get <input file> <output file>
!title 100% done

If you don't have the window handle then there are function in VB (this would be a VB question) that allow you to iterate through all top level windows and get there handle. With the handle you can query the window title. In the following example you could try to find the window with the title "FTP PROGRESS" and then count the + SIGNS in the title to know the progress:

Code: [Select]ftp <servername>
userid:
pwd:
!title FTP PROGRESS +
get <input file> <output file>
!title FTP PROGRESS ++
get <input file> <output file>
!title FTP PROGRESS +++
get <input file> <output file>
!title FTP PROGRESS ++++
get <input file> <output file>
!title FTP PROGRESS +++++

The nice thing is that you don't need to create an extra log file and the DOS Batch window will also show the progress.
Hope this helps :;
Thanks for ur idea..

is it possible to get the status of individual FLES downloading from ftp server?
iam still looking into getting title using window handle for dos window to get the status.
is ther any other simple way..?



Discussion

No Comment Found