Results 1 to 6 of 6

Thread: running an exe

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Folsom, CA USA
    Posts
    7

    Post

    im a newbie, so bear with me. could you show me how to make an exe that copies another exe to a specified directory, then run that exe


    thanks

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Put this in a Module, (Remove any Forms from the Project)..
    Code:
    Sub Main()
        FileCopy "C:\Files\MyFile.exe", "C:\NewDir\MyFile.exe"
        Shell "C:\NewDir\MyFile.exe", vbNormalFocus
    End Sub
    This copies the File: MyFile.exe from C:\Files to C:\NewDir Then Launches MyFile.exe before closing.

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  3. #3
    Guest

    Post

    i may be wrong, but couldnt you use a DOS batch file for this task??


  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Then you would have to worry about the distribution and proper placement of the batch file. Why not use 2 lines of code instead? What if he needed to dynamically create a new directory or pass parameters? Batch files are not that flexible....

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Folsom, CA USA
    Posts
    7

    Post

    well what im trying to do is put the files i want copied, onto a CD, so i can put in a system, and load up some programs when i click a button in a little menu. how can i tell it to copy the file, if its in the same directory as the exe. (since its would be on a cd-rom, the address wouldn't always be the same)

    Thanks

  6. #6
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    The App.Path Property returns the Directory Path from Which your Application was Launched, you can use this, ie.

    FileCopy App.Path & "\Files\MyFile.exe", "C:\NewDir\MyFile.exe"

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


Posting Permissions

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



Click Here to Expand Forum to Full Width