|
-
Dec 12th, 2005, 01:32 PM
#1
Thread Starter
Addicted Member
Timer needed
Any ideas on how to make a function wait on another function before it begins? I have a function that runs a batch file; the file takes around 5 minutes to run. The next function has to apply a filter on the resulting text file of the batch file. The filter applies too soon and sees that there is nothing to apply the filter to so the program ends. Here's some code:
VB Code:
Private Sub runBatch()
Shell ("INVENTORY_FTP.bat")
'Need to wait 5 minutes here
End Sub
-
Dec 12th, 2005, 01:37 PM
#2
Re: Timer needed
Why not just do a shellandwait until the batch file is done? You can do a search in the forum for that.
-
Dec 12th, 2005, 01:39 PM
#3
Re: Timer needed
Or, you could use this:
VB Code:
Shell ("Start /wait INVENTORY_FTP.bat")
which will wait until the batch file finishes.
you might need a cmd in there
-
Dec 12th, 2005, 03:01 PM
#4
Thread Starter
Addicted Member
Re: Timer needed
dglienna: It says File Not Found
-
Dec 12th, 2005, 03:14 PM
#5
Re: Timer needed
Not sure if it's the command, or that you don't have the path to the batch file.
Try adding the path to the batch file, and if that doesn't work, then this should
VB Code:
Shell ("C:\Windows\System32\cmd.exe /c " & _
"Start /wait INVENTORY_FTP.bat"), vbNormalFocus
-
Dec 12th, 2005, 03:37 PM
#6
Thread Starter
Addicted Member
Re: Timer needed
Actually I was wondering if shellandwait would work, but my program doesn't recognize the shellandwait command
-
Dec 12th, 2005, 03:41 PM
#7
Re: Timer needed
There is no command. It combines the same API's that start does.
http://vbforums.com/attachment.php?attachmentid=41200
Here is an example of shell and wait, though.
-
Dec 12th, 2005, 04:00 PM
#8
Thread Starter
Addicted Member
Re: Timer needed
That was a little too complex for me to understand.
-
Dec 12th, 2005, 04:05 PM
#9
Thread Starter
Addicted Member
Re: Timer needed
I've seen some other people using the shellandwait command in VB6. Is there something I need to add before my program recognizes that command?
Here's one of those threads:
http://www.vbforums.com/showthread.php?t=373660
-
Dec 12th, 2005, 04:13 PM
#10
Re: Timer needed
I posted what everybody was using. That's why I suggested Start /Wait. It's a lot simpler.
-
Dec 12th, 2005, 04:14 PM
#11
Thread Starter
Addicted Member
Re: Timer needed
True, let me try that again
-
Dec 12th, 2005, 04:43 PM
#12
Thread Starter
Addicted Member
Re: Timer needed
This code works:
VB Code:
Shell ("C:\Windows\System32\cmd.exe /c " & _
"Start /wait INVENTORY_FTP.bat"), vbNormalFocus
However, it opens two command windows. And doesn't close them.
But this code doesn't:
VB Code:
Shell ("Start /wait INVENTORY_FTP.bat"), vbNormalFocus
I'd like to have only one command window open and the window close after running the command
-
Dec 12th, 2005, 05:01 PM
#13
Re: Timer needed
Use the /B flag. Try start /? from a command prompt.
VB Code:
start /wait /b myfile.bat
and take off the last command to show focus. that was only for testing.
-
Dec 13th, 2005, 10:35 AM
#14
Thread Starter
Addicted Member
Re: Timer needed
Anyone know how to get around the fact that the file path contains a space when trying to run a batch file? It says "File NOT FOUND: G:\Finance\Inventory" If anyone can help me out I'd be most appreciative. Thanks. As always here's the code:
VB Code:
Shell ("Start /wait /b G:\Finance\Inventory Control\CycleCount\DB\deleteCycleCount.bat")
-
Dec 13th, 2005, 11:39 AM
#15
Re: Timer needed
Put your path and filename in quotes.
VB Code:
Shell ("Start /wait /b " & chr(34) & "G:\Finance\Inventory Control\CycleCount\DB\deleteCycleCount.bat" & chr(34))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|