file associations and file type

I am a liltle bit confused about the concept of file associations. In windows powershell 2.0, it says " Every Known file extension on a system has a corresponding file association. for example, if I type this " cmd /c assoc .bat" it will output this: ".batfile". If I type " cmd /c ftype batfile" I get {batfile="1%"%*} What I don't understand this being equal what does it really mean when a batch file is executed or any other program? If i changed the association from .bat=batfile to .bat=pigsflying would it prevent batch files from running? I guess what I am really asking is can the user name the association what he/she wishes?
KonfigurationKingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ThomasMcA2Commented:
AFAIK, file associations only tell Windows what application to launch when a file is double-clicked in the GUI. You can change what application is launched in the Folder Settings dialog. For example, you could tell RTF files to open in WordPad instead of MS Word.

I don't know if setting .bat=pigsflying would prevent batch files from running, but it would be easy to test.
0
Dave BaldwinFixer of ProblemsCommented:
In the Windows Registry, every file type and file extension have a list of associations.  You can have one association for the 'open' command and another for 'edit'.  You can edit a lot of the file associations for installed programs in the Folder Options under File Types.  BAT, COM, and EXE extensions are in the Registry and have the file type name associated with them along with a sub-key entitled 'PersistantHandler' which points to another place in the registry.  I know they can be changed because some viruses do that and there is a 'reg fix' to put the normal settings back in the registry.  But it is also a little more complicated than what you are suggesting.
0
KonfigurationKingAuthor Commented:
So what program is really running the batch file?
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

KonfigurationKingAuthor Commented:
For example the batch file has no association If I change that to CMD.EXE it will break the ability to run batch files. Why is that?
batch.JPG
0
ThomasMcA2Commented:
I see what you mean - my Win7 entry for ".bat" says the same thing as yours does.

Batch files are handled differently because they're executable. Your original question...
What I don't understand this being equal what does it really mean when a batch file is executed or any other program?
...is best understood with a non-executable extension, such as .doc.

File associations only matter when doing something in Windows Explorer. A file association launches an application (such as MS Word) when you double-click a file with a specific extension (such as .doc). The application then opens the file that you double-clicked.

There are additional Registry entries that let you define what appears on the right-click menu. Common menu options are Edit and Print, and it is even possible to create custom entries.
0
Dave BaldwinFixer of ProblemsCommented:
If I change that to CMD.EXE it will break the ability to run batch files.
Because you are breaking the internal associations that Windows would normally use.  I'm surprised that BAT is on that list because it really shouldn't be 'changeable' by users.  EXE and COM shouldn't be either.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KonfigurationKingAuthor Commented:
I guess I am somewhat satisfied with this answer but I still don't understand why when i click a batch file it pops up in CMD but if I associate with cmd it fails.
0
Dave BaldwinFixer of ProblemsCommented:
Unless you can write and trace the code that runs executables in Windows, you will never get a complete answer.  It's not as simple as you're trying to make it.  It's just easy to break.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.