Welcome to Dream.In.Code
Become a VB Expert!

Join 149,911 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,195 people online right now. Registration is fast and FREE... Join Now!




how does one duplicate an executable

 
Reply to this topicStart new topic

how does one duplicate an executable

oXiDe
31 Dec, 2007 - 12:30 PM
Post #1

New D.I.C Head
*

Joined: 17 Nov, 2007
Posts: 37



Thanked: 1 times
My Contributions
CODE
Private Sub Form_Load()
Dim tmp As String
Open App.Path & "\project1.exe" For Input As #1
Line Input #1, tmp
Close #1

Open "C:\copy.exe" For Output As #1
Print #1, tmp
Close #1
End Sub


when i open the copied file w/ a hex editor, its all jacked up sad.gif let alone it working when i execute it.

how does one copy the executable file for the project and paste it in another area in the computer.

User is offlineProfile CardPM
+Quote Post

Martyr2
RE: How Does One Duplicate An Executable
31 Dec, 2007 - 12:57 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Have you considered using the filecopy command?

CODE

Private Sub Command1_Click()
    FileCopy "c:/blahblah.exe", "c:/blabblah-copy.exe"
End Sub


If you are insisting to copy the way you are doing it using a loop, do remember that exe files are binary. So you have to open the files using binary (not just input) and use variables that can hold binary data instead of just strings.

Hope this points you in the right direction. smile.gif
User is offlineProfile CardPM
+Quote Post

oXiDe
RE: How Does One Duplicate An Executable
31 Dec, 2007 - 01:17 PM
Post #3

New D.I.C Head
*

Joined: 17 Nov, 2007
Posts: 37



Thanked: 1 times
My Contributions
dude ur so freakin awesome thx

i didnt know there was a file copy thing :|
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: How Does One Duplicate An Executable
31 Dec, 2007 - 01:20 PM
Post #4

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Glad I could be of some help. blush.gif
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: How Does One Duplicate An Executable
31 Dec, 2007 - 10:39 PM
Post #5

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,029



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Although I'd recommend the use of the FileCopy Command, let me tell you why your code didn't work.
CODE
Open App.Path & "\project1.exe" For Input As #1
Line Input #1, tmp
Close #1

The Line Input# Statement reads ONLY ONE LINE from a file. It doesn't read the entire contents. To make it read the entire file, you'll have to repeat the statement until the EOF (End of File) is reached.

The corrected code would look like this:
CODE
Private Sub Form_Load()

Dim tmp As String
Open App.Path & "\project1.exe" For Input As #1
Open "C:\copy.exe" For Output As #2
Do While Not EOF(1) 'Check for EOF
   Line Input #1, tmp ' Read a Line of Text
   Print #2, tmp        ' Write into file
Loop                       ' Repeat

Close #1
Close #2

End Sub

User is offlineProfile CardPM
+Quote Post

oXiDe
RE: How Does One Duplicate An Executable
2 Jan, 2008 - 09:34 AM
Post #6

New D.I.C Head
*

Joined: 17 Nov, 2007
Posts: 37



Thanked: 1 times
My Contributions
Ohhhhhh.. lol ahh so obvious. i knew that was too little of code when i tried it.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 01:55PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month