dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: How to wait for external processes to complete?

  1. #1
    Join Date
    Aug 2002
    Posts
    5

    How to wait for external processes to complete?

    After I run a .bat file through the shell function, how do I make the program for the .bat to finish doing it's "stuff" before continuing. I'm trying to access a file that the .bat file takes a sec. or 2 to create and I keep getting a "file does not exist error" because it hasn't been created yet.

  2. #2
    Join Date
    Aug 2001
    Posts
    1,447
    here's a thread I picked up a couple of days ago on exactly that topic
    Attached Files Attached Files

  3. #3
    Join Date
    Aug 2002
    Posts
    5
    Why are you sending me a .zip file??

    Is this some type of virus?? Could you just send me a link.

  4. #4
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868
    Search for CreateProcess, it's been posted a multitude of times...

  5. #5
    Join Date
    Aug 2002
    Posts
    5
    Will do, thanks and sorry for the repeat

  6. #6
    Join Date
    Aug 2001
    Posts
    1,447
    jeez fella, the ZIP file is just a zip of a text file that I copied off this board. as far as I'm aware, ZIP files can't be viruses unless you RUN an exe that they contain or open a Word file. This is a TEXT file.

    pardon me for trying to be helpful

  7. #7
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080
    You can use the WaitForSingleObject api and the createprocess api
    Nicolas Bohemier

  8. #8
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    Look at the end of this thread, you could always search for the List of active process (if you use CreateProcess, search with the PID) to see if the Process is still running.

    http://www.codeguru.com/forum/showth...0&pagenumber=2

    Alternatively, you sould check for Synchronization function, look for the API CreateSemaphore if you want to add a professionnal look at your application

    JeffB - hope it helps

  9. #9
    Join Date
    Aug 2002
    Posts
    5
    sorry about worrying about the .zip file, my bad, and thanks for the help. Probel is I'm not using VB I'm using a stupid Rational Rose scripting language that uses some VB and RR extensibility. I don't know how/if I can import packages. GRRR Ratioan Rose sux.

  10. #10
    Join Date
    Aug 2002
    Posts
    5
    How about this. I just pause the program for 10sec. and hope for a quick run time. what's the pause command in VB?? Sorry for the N00b questions, but my only VB book is in German.

  11. #11
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080
    You have to use the Sleep API for pausing your application.
    Nicolas Bohemier

  12. #12
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

    And, you could always trap the error and you could always see if the file exist before accessing it...

    JeffB

  13. #13
    Join Date
    Jun 2002
    Location
    Lyman ME - USA | Oneonta NY - USA
    Posts
    399
    Originally posted by phinds
    jeez fella, the ZIP file is just a zip of a text file that I copied off this board. as far as I'm aware, ZIP files can't be viruses unless you RUN an exe that they contain or open a Word file. This is a TEXT file.

    pardon me for trying to be helpful
    well viruses can be anything really, i can lace a zip and once it is run the pc is f*ed, BUT before the zip is run the person can check the file for a virus! lol don't be so quick to judge programs...Also exe's are usually not autorun so you can scan those as well....the ones you should realyl watch out for a pictures....could be anywhere...like on a web site etc...

    just my two cents

    - nc
    "In a world without walls and barriers, what need is there for windows and gates!" - a mac ad
    "What was the best thing before sliced bread and when did sliced bread go out of existence?" - me
    "Software is like sex, it's better when it's free." - Linus Torvalds <- gotten from Andreas Masur


    Live Penguine! - Tux the linux mascot
    Vivez le penguine!, ¡Viva en penguine!, Lang lebe der Pinguin!, Viva no penguine!, Viva sul penguine!

  14. #14
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080
    Viruses are not that bad..

    Worms are worse..

    Nicolas Bohemier

  15. #15
    Join Date
    Aug 2001
    Posts
    1,447
    I think the thread I posted in the ZIP uses the API, which should be available to you from whatever you're using. If the API isn't available, you may be out of luck.

    boogt, are you saying that the simple act of unZIPing a ZIP file can infect your PC w/ a virus???

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)