Valhalla Legends Forums Archive | Visual Basic Programming | Copy / Paste exe help.....

AuthorMessageTime
OuTLawZGoSu
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.
January 2, 2004, 1:55 AM
drivehappy
[quote author=OuTLawZGoSu link=board=31;threadid=4558;start=0#msg37984 date=1073008524]
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.
[/quote]

[code]
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
[/code]

I believe most of it's correct, I didn't use the VB IDE's autocomplete to check parameters.
January 2, 2004, 2:15 AM
Spht
[quote author=OuTLawZGoSu link=board=31;threadid=4558;start=0#msg37984 date=1073008524]
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.
[/quote]

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.
January 2, 2004, 2:19 AM

Search