Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: OuTLawZGoSu on January 01, 2004, 07:55 PM

Title: Copy / Paste exe help.....
Post by: OuTLawZGoSu on January 01, 2004, 07:55 PM
Aight, this is what i need.

- I need a program ( Program1 ) to copy it's self when you press Command1.
- Then paste that copy in a folder called "Folder2" in program1's folder.
- Then make a text file in Folder2 named "Log.txt", and print "Complete" in the text file.

If this can be done, plz let me know.
Title: Re:Copy / Paste exe help.....
Post by: drivehappy on January 01, 2004, 08:15 PM
Quote from: OuTLawZGoSu on January 01, 2004, 07:55 PM
Aight, this is what i need.

- I need a program ( Program1 ) to copy it's self when you press Command1.
- Then paste that copy in a folder called "Folder2" in program1's folder.
- Then make a text file in Folder2 named "Log.txt", and print "Complete" in the text file.

If this can be done, plz let me know.


Private Sub Command1_Click()
MkDir(AppPath, "Folder2")
Filecopy(AppPathAndFileName, AppPath & "\Folder2")
Open AppPath & "\Folder2\Log.txt" For Binary As #1
Put #1,,"Complete"
Close #1
End Sub


I believe most of it's correct, I didn't use the VB IDE's autocomplete to check parameters.
Title: Re:Copy / Paste exe help.....
Post by: Spht on January 01, 2004, 08:19 PM
Quote from: OuTLawZGoSu on January 01, 2004, 07:55 PM
Aight, this is what i need.

- I need a program ( Program1 ) to copy it's self when you press Command1.
- Then paste that copy in a folder called "Folder2" in program1's folder.
- Then make a text file in Folder2 named "Log.txt", and print "Complete" in the text file.

If this can be done, plz let me know.

It can be done, yes.

Did you want to know how? Use FileCopy to move the file (or MoveFile API). I believe you need to be on a NT system to rename/move(?) running executables. You can use the MkDir statement to create the folder if it doesn't already exist.  Use the Open statement to access a file and write to it.