Important alert: (current site time 7/16/2013 1:54:24 AM EDT)
 

VB icon

***Convert TXT file to Executable EXE***

Email
Submitted on: 6/12/1999
By: Atanas Matev  
Level: Not Given
User Rating: By 16 Users
Compatibility: VB 5.0, VB 6.0
Views: 90699
 
     This code convert a TXT file to EXE file.When you convert the file start the EXE and the old file will be typed(like TYPE command) This is really great code NOTE : RUN THE .EXE FROM MS-DOS MODE
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: ***Convert TXT file to Executable EXE***
' Description:This code convert a TXT file to EXE file.When you convert the file start the EXE and the old file will be typed(like TYPE command)
This is really great code
NOTE : RUN THE .EXE FROM MS-DOS MODE
' By: Atanas Matev
'
' Assumes:Create a label, a command button and common dialog control
Change the Caption of the button to "Select a file"
And that's all
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2071&lngWId=1'for details.'**************************************

Dim a(14) As Byte
Dim i As Integer
Public Function HiByte(ByVal wParam As Integer)
 HiByte = wParam \ &H100 And &HFF&
End Function
Public Function LoByte(ByVal wParam As Integer)
 LoByte = wParam And &HFF&
End Function
Private Sub Command1_Click()
 On Error GoTo 10
 
 a(0) = 190
 a(1) = 15
 a(2) = 1
 a(3) = 185
 a(4) = 0
 a(5) = 0
 a(6) = 252
 a(7) = 172
 a(8) = 205
 a(9) = 41
 a(10) = 73
 a(11) = 117
 a(12) = 250
 a(13) = 205
 a(14) = 32
 CommonDialog1.Filter = "Text Files|*.txt|"
 CommonDialog1.Action = 1
 
 Open CommonDialog1.filename For Input As #1
 sourcelen = LOF(1)
 Close #1
 
 a(4) = LoByte(sourcelen)
 a(5) = HiByte(sourcelen)
 
 newfilename = Left(CommonDialog1.FileTitle, Len(CommonDialog1.FileTitle) - 4) & ".exe"
 If MsgBox("Are you sure you want to convert `" & CommonDialog1.FileTitle & "` to `" & newfilename & "`", vbYesNo, "Confirm") = vbNo Then Exit Sub
 Open CommonDialog1.filename For Input As #1
 Open newfilename For Output As #2
 t = Input(LOF(1), 1)
 For k = 0 To 14
 st = st & Chr(a(k))
 Next k
 st = st & t
 Print #2, st
 Close #1
 Close #2
 Label1.Caption = "Converted successful"
 Exit Sub
10
 Label1.Caption = "Error"
End Sub


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
6/12/1999 5:49:00 PMcaspercia

COol code!! I can't wait to try it!!!! Keep up the good work
(If this comment was disrespectful, please report it.)

 
6/13/1999 3:23:00 AMLasse Hassing

It doesnt work ("test1.exe is not a valid win32 application")
(If this comment was disrespectful, please report it.)

 
6/13/1999 5:16:00 AMJohn Atanasov

That's really great code
It works perfectly

(If this comment was disrespectful, please report it.)

 
6/13/1999 7:05:00 AMAndrew

Make sure that you run it in MS-DOS mode. It isn't working because you're running it from windows.
(If this comment was disrespectful, please report it.)

 
7/8/1999 2:31:00 PMSahajo

Instead of complaining about how you have to run the resulting executable in DOS mode, why dont you simple have it so the program creates a file with extension ".com"? Command files (.com) will run under windows, and the exe files can easily be changed to a .com file simply by changing the extension... they are formatted correctly. Is this not a better solution? It works fine for ME...
(If this comment was disrespectful, please report it.)

 
7/27/1999 8:41:00 PMEsplin9466

How do you add scrollbars to the com/exe file you make? mine just zooms onat lihgt speed.
(If this comment was disrespectful, please report it.)

 
8/17/1999 9:52:00 AMramanuj

Great, its something what I was looking for
months, but didn't get it.
May I know the way the exe header works.

Nice program...keep it up.
(If this comment was disrespectful, please report it.)

 
11/26/1999 7:18:00 AMBryan Cairns

Very Nice code :)
(If this comment was disrespectful, please report it.)

 
1/28/2000 3:12:47 PMUltimatum

Great! =) Now all I need is the source code in VB to a C compiler or something =)
(If this comment was disrespectful, please report it.)

 
2/22/2000 11:44:00 PM[]D[][]V[][]D

Very nice code and it brought up an interesting consept. If this can turn text files into .com's (note: if you change the code a bit or just rename ext manually), can you make it turn .com's into text files?

Please reply to this as soon as possible,

[]D[][]V[][]D

P.S. Keep up the great coding.
(If this comment was disrespectful, please report it.)

 
3/26/2000 9:13:08 AMJonathan

Great code

(If this comment was disrespectful, please report it.)

 
5/15/2000 8:18:06 AMDISEASE_2000

[]D[][]V[][]D: It's possible to convert *.COM to *.TXT.

Great code Author. But there's a better way you can convert *.txt to *.exe which will run fine even if you're in window.
(If this comment was disrespectful, please report it.)

 
8/26/2000 7:44:01 PMLinda

Do you know how to convert a textfile to a binary file?
Please send me the code fastly as you can. Thank-you!!
(If this comment was disrespectful, please report it.)

 
12/23/2000 6:52:04 PMJulien Gascon-Samson

Sorry...
Sure... Try converting .txt to .exe directly in explorer. You'll see what it does... Especially with Norton Crashguard!
(If this comment was disrespectful, please report it.)

 
2/17/2001 8:31:04 AMheader

how does the header work
you could use this to make awsome stuff
like your own background picture/color, foreground pictures/colors
(If this comment was disrespectful, please report it.)

 
10/23/2001 4:45:00 AMVisual Basic

lol
i ran the exe under windows 2000 and it went completely wacko then came the complete hault of my cpu.

p3 933mhz, 540mb ram
(If this comment was disrespectful, please report it.)

 
12/2/2001 10:40:01 AMtHe_cLeanER

worx fine from windows in XP
(If this comment was disrespectful, please report it.)

 
12/11/2001 5:30:32 PMEric Hodges

Awesome Code. Works great under NT. And i tried that whole just rename a txt file thing and it didn't work so this is realy good stuff.

Thanks for your contribution.
(If this comment was disrespectful, please report it.)

 
12/17/2001 2:25:15 PMthamuz

I haven't been able to try it out yet, but it looks awesome. Im gonna start work on a convert txt to exe/com and com/exe to txt code snippet tonight.
(If this comment was disrespectful, please report it.)

 
2/20/2002 4:59:59 PMDavid

Nifty code. If anyone has some stuff like this (e.g. how to make MS-DOS programs) I'd appreciate an e-mail. Keep up the good work.
(If this comment was disrespectful, please report it.)

 
5/29/2002 11:14:30 PMTom

c:>type filename.exe

????????????????????????
(If this comment was disrespectful, please report it.)

 
7/25/2002 9:30:27 AMMichiel Schermer

MMMMhhh.. some sources are a waste of my time in my 11 years programming, and this is a perfect example of that kind of codes... why do we want to compile a text file to a EXE.. doesnt the VB compiler handle that already for us... computer should make it ourselves easer
(If this comment was disrespectful, please report it.)

 
9/8/2003 2:16:46 AMAchindra Bhatnagar

The code is really fine. What I was looking for is a method to add my exe file pointer to the header of any other executable, so that each time the original executable is run, my code executes before that and check for authority. This is going o run like a virus but for good sake. This will help me in acheiving a certain level of security. This will help me in implementing security to the system. Your code is definetly going to lead me forward in my work. Thanks.
Hay if anyone could help me in that, I would b pleased. Do write to me...
(If this comment was disrespectful, please report it.)

 
10/23/2003 11:37:16 PMMian Naeem

awsome code...

can you please tell me what is logic of the working of the header of this exe file..or can you give me the link which explain it better how the header of exe works in situation like this...
please do reply to me...
Thanx
----------
(If this comment was disrespectful, please report it.)

 
11/25/2003 9:02:20 AM

GREAT SITE!
(If this comment was disrespectful, please report it.)

 
12/24/2003 6:04:39 AM

student
(If this comment was disrespectful, please report it.)

 
8/31/2004 8:34:38 AM

source code

(If this comment was disrespectful, please report it.)

 
9/11/2004 4:22:06 PM

Thanks =)
(If this comment was disrespectful, please report it.)

 
1/22/2005 4:37:37 PMAndrew Cooke

Adam&Faraz Kachwalla(the Superbrothers)

run it from msdos/cmd/command prompt

go start, run, type cmd. Then drag and drop the exe into the new blackwindow, press enter, and bam, done
(If this comment was disrespectful, please report it.)

 
2/18/2005 8:18:20 PM

www.pirateculture.net/Dir has some cool codes as well and we will explain how they work if you ask ;
(If this comment was disrespectful, please report it.)

 
6/18/2005 11:14:01 PM

very nice code
(If this comment was disrespectful, please report it.)

 
9/17/2005 1:14:40 AMKuangda He

(\,,,/)
(0.o) < Great Stuff >
(> <)
(If this comment was disrespectful, please report it.)

 
11/22/2005 2:27:10 AMDarkSoul

for some reason after creating the exe file my cpu is at 100% usage and the files cannot be deleted even after a reboot.
how do i delete the created exe files?
(If this comment was disrespectful, please report it.)

 
1/14/2006 4:34:24 PMErik

Very good! "Excellent"-vote from me
(If this comment was disrespectful, please report it.)

 
7/13/2006 6:08:48 AMxunhacker

非常不错!
(If this comment was disrespectful, please report it.)

 
2/12/2007 1:33:45 PMswapnil

1111
(If this comment was disrespectful, please report it.)

 
6/21/2007 11:01:14 PMPhill Chen

Excellent Code. CoOoOoOoool.....
(If this comment was disrespectful, please report it.)

 
5/25/2008 10:13:50 PMPhunk

Nice and great code :) thanks for share!
(If this comment was disrespectful, please report it.)

 
7/29/2008 7:27:44 PMsami

very great code
thanks
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.