Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
| Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2003, 08:31 AM
Authorized User
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Waiting for a batch file to finish

Folks

I'm using a bit of code to create a batch file, that copies the file structure into a text file:

'create a batch file
Open strDrive & "q.bat" For Output As #intFreeFile
        Print #intFreeFile, "xcopy " & strDrive & "*.* d:\ /e/c/l/h/r/y > " & strDrive & "myFiles.txt"
Close #intFreeFile

I then run the batch file:

dblRetVal = Shell(strDrive & "q.bat", vbHide)

Once the file has completed I want to "kill" the batch file. How can I do this (if its possible of course)?

I thought that if I try to open the file that its writing to before its complete it would generate an error. So if I could write a loop of some sort that tries to access the file say, every 5 seconds, if its not finished, it will error, so re-start the timer, whereas when I can open the file, it must mean the batch file is completed...

You can see I'm a newbie can't you... :-) does this make sense, is it possible, or is there any easier way? I'm not specifically looking for a bit of code as an answer, just a point in the right direction, otherwise I'll never learn.

Cheers


Regards

Russ (Programing on L plates..!)
__________________
Regards

Russ (Programing on L plates..!)
 
Old June 21st, 2003, 11:29 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

check out this link, it should do what you want:

http://www.vbaccelerator.com/codelib/shell/shelwait.htm
 
Old June 21st, 2003, 02:06 PM
Authorized User
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Phillip

Thanks for the response, I'm not sure I fully understand the code but I'll give it a try...

:-)



Regards

Russ (Programing on L plates..!)
 
Old June 22nd, 2003, 04:24 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You dont always need to understand it, Russ, you just need to get paid for it :D

Quote:
quote:Originally posted by fordrs3
 Phillip

Thanks for the response, I'm not sure I fully understand the code but I'll give it a try...

:-)



Regards

Russ (Programing on L plates..!)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Invoking a batch file from servlet vinayreddy Servlets 3 October 24th, 2008 02:12 AM
Need Help with DOS batch file .. Arul20 Forum and Wrox.com Feedback 5 August 31st, 2007 06:51 AM
Telnet dos batch file sridharaiyer Need help with your homework? 0 August 25th, 2006 03:38 PM
Batch File Allan320 Access 10 June 8th, 2006 06:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.