2011年12月14日 星期三

How to change a file association with command line in Windows system (XP, Vista, 7)?

To change a file association with command line in Windows system (XP, Vista, 7)

Two commands are involved, assoc & ftype.

Example No1: 

We want to use Notepade++ to open text file instead of Notepad.

C:\assoc .txt

.txt=txtfile

C:\ftype txtfile

txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1

ftype txtfile="C:\Program Files\Notepad++\notepad++.exe" "%1"

 

Example No2:

We have a customized application, ezPGPClient, which can encrypt and decrypt files with PGP standard.

It's located in C:\pnab\program\ezpgp\ezPGPClient.exe

The file extensions will be associated are .gpg and .pgp and there is no other program had been set up to association with them.

C:\assoc .gpg=pgpfile

# This command assign .gpg to be pgpfile

 

C:\assoc .pgp=pgpfile

# This command assign .pgp to be pgpfile

 

C:\ftype pgpfile=C:\pnab\program\ezpgp\ezPGPClient.exe %1

# This command assign pgpfile to be opened by the given program with absolute path.

沒有留言: