Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Difference between *.com and *.bat under W2K

Posted on 2002-03-25
21
Medium Priority
?
426 Views
Last Modified: 2010-04-14
My question is:
What is the difference between .com file and .bat file.
I mean internals, how they are executed by the kernel and differences in memory allocation etc.
0
Comment
Question by:omk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
  • 4
  • +2
21 Comments
 
LVL 2

Author Comment

by:omk
ID: 6894889
I am intersted only in Windows 2000.
Thanks
0
 
LVL 11

Expert Comment

by:griessh
ID: 6894924
exe and com files are binaries that are loaded into memory and executed. A com file has one special feature, the executable will fit in one 64KB segment (they were created in the early DOS days when RAM was still precious ...).

A bat file is first of all a text file. This text file contains commands that could be run from a command line. Instead of doing this manually, the command interpreter will open a new shell for you and then execute the commands in the bat file. (So writing your own batch interpreter isn't too difficult, you need to read a text file that follows a few rules and then you do a ShellExec()).

And that is valid for all Windows versions.

I guess that's not enough for you (300 points?), but you will have to be a bit more specific about what you need to know.

======
Werner

0
 
LVL 16

Expert Comment

by:Kyle Schroeder
ID: 6895093
Did you maybe mean the difference between .bat and .cmd?  To the best of my knowledge, the only difference there is a .cmd is only executable under an WinNT (NT 3.x, NT 4.x, Win2K, WinXP) environment, while a .bat will run in either.  .cmd is used to designate that the file is for NT, and may contain NT specific commands.

-dog*
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Author Comment

by:omk
ID: 6895259
I mean exactly what I mean, what is the difference between say test.bat and test.com under windows 2000.
Say I have test.bat. Then I rename it to test.com.
Then I create a shortcut to test.com. Then I rename test.com back to test.bat. Then I edit the shortcut so that it still point to this test.bat. So my question is why the system treats this test.bat different, than if I siply created a shortcut to initial test.bat.
FYI these are DIFFERENT.
0
 
LVL 16

Expert Comment

by:Kyle Schroeder
ID: 6895281
What?  First I wonder why you're spending so much time renaming bat files and editing their shortcuts...but I'm sure you must have a reason...

What do you mean that "the system treats this test.bat different"?

OK...I worked through your strange question, and I think I know what you are talking about.  When you make a shortcut to a .com file, its not just a typical .lnk file.  If you examine the shortcut, it is actually test.com.pif.  The .pif indicates that the program it is targeted at is a MS-DOS .EXE or .COM program.  Creating a shortcut to test.bat creates a file test.bat.lnk.  A .lnk (link) file is a standard Windows shortcut that can be used for any file (except the abovementioned MS-DOS .COM or .EXE file) or even a folder.  Windows processes .LNK files differently than .PIF files; if you are extremely curious as to the low-level "what's happening exactly" differences, you might want to check the Windows 2000 Resource Kit which you can purchase at most bookstores that carry computer books, or direct from Microsoft, Amazon, BN.com, etc....

-dog*
0
 
LVL 2

Author Comment

by:omk
ID: 6895294
OK,
It is very close.
say i have ResKit, can you point where I can find detailed explanation there?
0
 
LVL 2

Author Comment

by:omk
ID: 6896107
You can look thru this link with related (not the same) issue
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q139628
I really curious what happens on the lowest level as it is only possible with Microsoft products.
I am not able to give more than 300 points for a single question, but I will raise it up to a 1000 points for a complete answer.
0
 
LVL 2

Expert Comment

by:xchange
ID: 6909779
So, as werner pointed out, the system will EXECUTE a .com file. Whereas in the case of a .bat file the system will execute COMMAND.COM instead and pass it the '.bat file's name as a parameter.

 So, in BOTH cases, a .com file is run actually.
The difference is when you run it from!
a) From the desktop as an icon: The system will set-up the .com's environment accordinf to user-defined settings that can be found by rclick | properties (Memory, etc.)
b) From the Command-Line: The system will set-up the .com's environment to be similar to the Command-line's (Command.com), .com will inherit it from command.com process.

Just another litle point:
 If at the command prompt you do not specify an extension, .com files are executed in favor of .bat files.

---
Theo
0
 
LVL 2

Author Comment

by:omk
ID: 6909999
to xchange
Thanks for your comment.
Say you know that cmd and command are different?
My question is HOW it is executed.
To grasp an idea: almost everybody can drive a car,
signifficantly less can test and repair it, but there are only a few who know exactly what happens in your engine.
I seach for assistance of those few.

Thanks
0
 
LVL 11

Expert Comment

by:griessh
ID: 6910071
omk

exe and com files have a header that keeps informations about the binary (stack, memory etc).

You can always do a search in your favourite search engine for "exe header" ... here is one link I used: http://www.delorie.com/djgpp/doc/exe/

======
Werner
0
 
LVL 2

Author Comment

by:omk
ID: 6910211
Yes, this header is used for memory allocation.
I also have a description of undocumented pif structure.
Please read carefully my "rename" explanation of the issue,
I do not change file headers.
dogztar explained very well the visible difference between pif and lnk.
The results that I have with this "renaming" are so exiting, that I decided to find out the internals.
I need the level of explanation similar to "Inside Microsoft Windows 2000"

Thanks a lot
 
0
 
LVL 11

Expert Comment

by:griessh
ID: 6910256
omk

I am really not sure what you try to accomplish. Could you give us some idea WHAT you want to do by renaming .bat to .com and back and forth?

======
Werner
0
 
LVL 2

Author Comment

by:omk
ID: 6910771
I already have the result. But I need to understand what actually happens. With this funny renaming you can receive access to a very protected system resources.
0
 
LVL 2

Expert Comment

by:xchange
ID: 6912249
dog, are you sure that you get a .lnk for .bat files?
I have WinME :(, but when I create shortcuts for .com and .bat files, .pif files are created in both cases!
 Can someone with Win2k actually verify this? And also verify if Win2k  uses command.com or cmd.exe(?) for executing .bat files?

omk> I already have the result.
What result?
0
 
LVL 2

Author Comment

by:omk
ID: 6912874
to xchange
I have mentioned that I am interested in windows 2000 ONLY,
not in DOS systems as Win ME.

Thanks
0
 
LVL 11

Expert Comment

by:griessh
ID: 6914084
omk

>>DOS systems as Win ME
That is an insult for DOS!

======
Werner
0
 
LVL 2

Expert Comment

by:xchange
ID: 6917844
...moreover: WinME is not a DOS system (at least not more than W2k).
Probably you COULD say that for Win_3x and Win9x series but not for WinMe.

Anytime.
0
 
LVL 16

Expert Comment

by:Kyle Schroeder
ID: 6918620
Really...hmm.  I'm very sure that WinME still has a lot of nasty 16bit code deep in its kernel and core files...They would like you to believe its all 32bit, but its just not true.
0
 
LVL 11

Expert Comment

by:ewtaylor
ID: 8905489
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[split dogztar griessh xchange]
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
[ewtaylor]
EE Cleanup Volunteer
0
 
LVL 16

Accepted Solution

by:
Kyle Schroeder earned 1200 total points
ID: 8905822
Also...WinME is *PART* of the Win9x series...
0
 
LVL 2

Author Comment

by:omk
ID: 8909794
I like dogztar approach. I give him points because he tried.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question