Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: Checking if shell-statement is finished

    I already have an other question.

    I need to copy a file from one location to another.
    Now I'm using Shell ("c:\move.bat",vbHide).
    move.bat is just a batch-file with a copy-statement.

    first question : Is it OK to use DOS or should I do such thing in VB?
    If the answer is VB --> how can I do this?

    second question : moving the file takes some time.
    How can I detect if it is finished.
    I was thinking about checking the Windows-process using the variable which I get from the Shell-statement. But how do I write this in VB?

    Is there anyone who can help me out?

    Thanks

  2. #2
    Join Date
    Mar 2003
    Location
    London
    Posts
    40

    Re: Checking if shell-statement is finished

    It requires very advanced programming to establish that a DOS prompt has finished. (Can tell you how to do it if you need it)

    Do it in VB

    FileCopy <Source>, <Destination>
    Kill <Source>

  3. #3
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Re: Checking if shell-statement is finished

    Originally posted by yk58301
    It requires very advanced programming to establish that a DOS prompt has finished. (Can tell you how to do it if you need it)

    Do it in VB

    FileCopy <Source>, <Destination>
    Kill <Source>
    If you don't mind I really want to know it.

    Thanks.

    By the way : I tried copying the file using the FileCopy-statement and I always get a "permission denied-error" .
    The file is located on another server, but I got got administrator-rights .
    Using my Windows Explorer I have no problems to reach and even modify the file.
    Any ideas?
    Last edited by artemide; 03-31-03 at 02:46.

  4. #4
    Join Date
    Mar 2003
    Location
    London
    Posts
    40

    Re: Checking if shell-statement is finished

    Under Win2K, filecopy will fail if the file you are trying to copy is in use by another application.
    You have 2 options here:
    1) Free file by closing all applications that have it open
    2) Write your own copy routing in VBA (using open statement (open as read-only etc...))

    As for tracking a DOS process:
    You can use windows api functions in VB to iterate through windows.
    IF your DOS process window has a unique name (which you can ensure by giving a unique name to the .bat file you are running), you can loop through all windows until you can't find the DOS-process one.

    Unfortunately there's no more stable way of doing it, as process tracking in Win95 is different from 97 and different from 2K (2K is similar to NT).

    Let me know if you need more info, or go to MSDN (there's an article on process tracking there somewhere)

Posting Permissions

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