PDA

Click to See Complete Forum and Search --> : running an exe


durgon
Jan 5th, 2000, 12:53 AM
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

Aaron Young
Jan 5th, 2000, 12:59 AM
Put this in a Module, (Remove any Forms from the Project)..

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
aarony@redwingsoftware.com
ajyoung@pressenter.com

Jan 5th, 2000, 02:20 AM
i may be wrong, but couldnt you use a DOS batch file for this task??

Clunietp
Jan 5th, 2000, 02:23 AM
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....

durgon
Jan 5th, 2000, 02:47 AM
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

Aaron Young
Jan 5th, 2000, 03:42 AM
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
aarony@redwingsoftware.com
ajyoung@pressenter.com