Monday, November 22, 2010

File Associations from the command line (ie. in a batch file)

In all of my years of administering workstations, I haven't had to use this until today.  I was surprised to learn that is has been around about as long as I have been administering workstations.

Two commands, ASSOC and FTYPE, allow you to manage file associations from a command prompt (or in a batch file).

Typing ASSOC, without parameters, displays the currently defined extensions.
Type ASSOC .{ext} to display the .{ext} file association.
Typing ASSOC .{ext}= will delete the .{ext} association.

Typing FTYPE without options displays the file types that have defined open command strings.
Typing FTYPE {AppName} will display the open command string for the file type {AppName}.
Typing FTYPE {AppName}= will delete the open command string.

To define a new association for .mug files which you want to open with mspaint:
assoc .mug=MugShot
ftype MugShot=%Systemroot%\System32\mspaint.exe %1

For a complete explanation, type ftype /? or assoc /? at a command prompt.

Here are a couple other references too:

No comments:

Post a Comment