Computer Hope

Microsoft => Microsoft DOS => Topic started by: macdad- on February 14, 2008, 02:46:33 PM

Title: Can u Convert a COM File back into a Batch File?
Post by: macdad- on February 14, 2008, 02:46:33 PM
i have found that you can convert your batch programs into com files but can you convert a com file back into a batch file?
Title: YES!
Post by: SOAP on February 14, 2008, 04:29:33 PM
Ya, just rename it from .bat to .com, and if that doesn't work it means that your settings are set where it doesn't show the extensions.
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: patio on February 14, 2008, 05:08:56 PM
Somehow i don't think this experiment will work...
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: SOAP on February 14, 2008, 08:08:17 PM
It works for me. If you just make a .bat file and change it to a .com you can change it back. Try it if you got time.
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: llmeyer1000 on February 15, 2008, 12:50:20 AM
Patio was way too nice.

Why don't you try your wee little experiment on a real .com file instead of a batch file that  you simply renamed incorrectly. Then open your new "batch" file and see if you can edit it.

Title: Re: Can u Convert a COM File back into a Batch File?
Post by: Sidewinder on February 15, 2008, 05:21:51 AM
Quote
i have found that you can convert your batch programs into com files but can you convert a com file back into a batch file?

Doubtful. You might find a disassembler that would make it somewhat readable, but don't count on any program turning it back into the original text file.

Quote
It works for me. If you just make a .bat file and change it to a .com you can change it back. Try it if you got time.

Quote
Ya, just rename it from .bat to .com, and if that doesn't work it means that your settings are set where it doesn't show the extensions.

This would be interesting if it were true. COM files are executables that generally run inside the shell program. BAT files are text files that need an interpreter to run in the shell program. They are not interchangeable and it's unlikely the operating system would mistake one for the other.

 8)
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: Dias de verano on February 15, 2008, 06:16:17 AM
The way many of these these batch-to-com and batch-to-exe "compilers" work is by attaching an executable  header to the submitted batch file. The header contains an interpreter rather like cmd.exe or command.com, but often it will only handle a subset of the full range of commands. When the executable file is run, the interpreter gets to work on the attached embedded batch script  I guess one could examine such a "compiled" com file in a hex editor and view the original batch file therefore, and also determine where to cut in order to retrieve it.

Of course it a true compiler was used, and machine code produced, a disassembler would need to be used, but it wuld be unlikely to produce anything very comprehensible.
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: RCSINJ on February 15, 2008, 09:24:18 AM
Changing the name of the extension from bat to com or anything else doesn't change the file or how it runs. " A rose by any other name would still be a rose" whether it smells as sweet or not
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: Dias de verano on February 15, 2008, 09:43:41 AM
Changing the name of the extension from bat to com [...] doesn't change [...] how it runs.

That is not true. The OS will try to execute a batch one way, and a .com another way. Changing the extension either way will make the file impossible to execute.

Quote

C:\>type tryme.bat
@echo off
echo %date% %time% Hello World
echo.

C:\>tryme.bat
15/02/2008 16:30:10.29 Hello World

C:\>ren tryme.bat tryme.com

C:\>tryme.com
Cannot execute C:\TRYME.COM


[/list]
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: macdad- on February 15, 2008, 01:56:02 PM
ok i guess i didnt make it fully clear. i want to convert com files back into batch files. all the graphics the com files have made me curious and i wondered how can i make these graphics (boxes, borders, and backgrounds)
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: Dias de verano on February 15, 2008, 01:59:16 PM
ok i guess i didnt make it fully clear. i want to convert com files back into batch files.

I guess we didn't make it fully clear either. You can't.
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: macdad- on February 15, 2008, 03:11:08 PM
oh then how do can u make the boxes backgrounds and all the special graphics in com files?
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: Dusty on February 15, 2008, 05:14:43 PM
Echo the special characters (Alt+keypad number) for what you want.

Title: Re: Can u Convert a COM File back into a Batch File?
Post by: macdad- on February 15, 2008, 05:30:23 PM
are the keypad #'s the ASCII # for the characters?
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: Dusty on February 16, 2008, 01:47:36 AM
Yes, the ASCII codes are shown >>here (http://www.cdrummond.qc.ca/cegep/informat/Professeurs/Alain/files/ascii.htm)<<.

Title: Re: Can u Convert a COM File back into a Batch File?
Post by: macdad- on February 16, 2008, 07:16:52 AM
thanks!
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: macdad- on February 16, 2008, 07:29:02 AM
ah crud. i used the ASCII characters in my batch file but they come out as different characters when i run the batch file.
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: llmeyer1000 on February 16, 2008, 08:12:23 AM
YES,
You can type most of the 256 ASCII charactors with the ALT-123 method, but be careful with the first 32 & the last one(ALT-255). Many of these have special functions that will give you unexpected results. I think most of the rest are safe. Use the space bar, unless you have a specific reason for the blank(ALT-255).

Also some of the charactors appear differently in one editor than than they do in another. Try the blank(ALT-255). In this window, it appears correctly(it looks a lot like a space(ALT-32) but is a completely different charactor.) In DOS editor for WindowsXP, it appears correctly also, but in some of the older versions, DOS 6.22 - Windows 98, It shows up as a visible charactor on the screen. In Note Pad you may get entirely different results. Some of the charactors can be typed only with a HEX editor, which is not what you want to do here.

Sometimes DOS Editor will not save the charactor as typed, especially the first 32. DOS Editor in XP has Save as Type - Unicode. This might help, but I doubt it, if you are trying to use the special charactors. I don't know whether Unicode was available in earlier versions or not.

WOW! we are way off on a tangent here, aren't we???
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: Dusty on February 16, 2008, 02:12:26 PM
ah crud. i used the ASCII characters in my batch file but they come out as different characters when i run the batch file.

Sorry, should have mentioned that I use Edit.com in XP and W2k to create the script as this ties in with the 'Dos' side of things, not sure what other editors will produce.

Apols.
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: macdad- on February 17, 2008, 03:44:02 PM
oh then i'll try edit
Title: Re: Can u Convert a COM File back into a Batch File?
Post by: SOAP on February 17, 2008, 04:26:08 PM
Man was i wrong ( I wasn't even in the ball park). Thanks for setting me straight patio and llmeyer.