批处理ASSOC命令

它是将扩展名与文件类型(FTYPE)相关联的批处理命令,显示现有关联或删除关联。

语法

assoc – Displays all the file extensions 
assoc | find “.ext” – Displays only those file extensions which have the extension ext.

示例

将以下代码保存在文件:assoc.bat 中,如下所示 -

@echo off 
assoc > F:\worksp\batch_script\lists.txt 
assoc | find ".doc" > F:\worksp\batch_script\listsdoc.txt

文件关联列表将定向输出到文件lists.txt。以下输出显示了运行上述批处理文件后,listsdoc.txt文件中的内容。

F:\worksp\batch_script>assoc.bat

listsdoc.txt文件中的内容 -

.doc=Word.Document.8
.dochtml=wordhtmlfile
.docm=Word.DocumentMacroEnabled.12
.docmhtml=wordmhtmlfile
.docx=Word.Document.12
.docxml=wordxmlfile

上一篇: 批处理命令 下一篇: 批处理文件