在 Windows 7 中删除文件类型关联

Nat*_*055 14 windows-7 file-types filetype

我已经设置了一个自定义文件关联.cfg以在WordPad 中打开,但我似乎无法弄清楚如何删除它。如何删除 Windows 7 中的文件关联?

Kev*_*gan 15

在命令窗口中,您可以使用“ASSOC”和“FTYPE”命令来添加/编辑/删除文件类型关联。

C:>assoc /?  

ASSOC [.ext[=[fileType]]]  

  .ext      Specifies the file extension to associate the file type with  
  fileType  Specifies the file type to associate with the file extension  

Type ASSOC without parameters to display the current file associations.  
If ASSOC is invoked with just a file extension, it displays the current  
file association for that file extension.  Specify nothing for the file  
type and the command will delete the association for the file extension.  
Run Code Online (Sandbox Code Playgroud)

和:

C:>ftype /?  

FTYPE [fileType[=[openCommandString]]]  

  fileType  Specifies the file type to examine or change  
  openCommandString Specifies the open command to use when launching  
  files of this type.  

Type FTYPE without parameters to display the current file types that  
have open command strings defined.  FTYPE is invoked with just a file  
type, it displays the current open command string for that file type.  
Specify nothing for the open command string and the FTYPE command will  
delete the open command string for the file type.  Within an open  
command string %0 or %1 are substituted with the file name being  
launched through the assocation.  %* gets all the parameters and %2  
gets the 1st parameter, %3 the second, etc.  %~n gets all the remaining  
parameters starting with the nth parameter, where n may be between 2 and 9,  
inclusive.  

... ...  
Run Code Online (Sandbox Code Playgroud)

所以(在我的系统上),关于 .bkr 文件,这些命令返回:

C:>assoc .bkr  
.bkr=bkrfile  

C:>ftype bkrfile  
bkrfile="F:\Program Files\path...\program.exe" "%1"  
Run Code Online (Sandbox Code Playgroud)

我创建了一个新的“测试”文件扩展名/文件类型(可能需要管理员权限):

C:>assoc .bzb
File association not found for extension .bzb

C:>assoc .bzb=MyBZBCustomFileType  
.bzb=MyBZBCustomFileType  

C:>assoc .bzb
.bzb=MyBZBCustomFileType  

C:>ftype MyBZBCustomFileType  
File type 'MyBZBCustomFileType' not found or no open command associated with it.  

C:>ftype MyBZBCustomFileType=%SystemRoot%\system32\NOTEPAD.EXE %1  
MyBZBCustomFileType=C:\Windows\system32\NOTEPAD.EXE %1  

C:>echo Some text.>C:\Temp\file.bzb  

C:>start "" C:\Temp\file.bzb  
Run Code Online (Sandbox Code Playgroud)

这将打开“记事本”编辑我的“虚拟”文件。

要删除文件类型关联,首先删除文件类型与程序的连接,如下所示:

C:>ftype MyBZBCustomFileType  
MyBZBCustomFileType=C:\Windows\system32\NOTEPAD.EXE %1  

C:>ftype MyBZBCustomFileType=  
File type 'MyBZBCustomFileType' not found or no open command associated with it.  
Run Code Online (Sandbox Code Playgroud)

然后删除文件扩展名关联(可能需要管理员权限):

C:>assoc .bzb  
.bzb=MyBZBCustomFileType  

C:>assoc .bzb=  

C:>assoc .bzb  
File association not found for extension .bzb  

C:>start "" C:\Temp\file.bzb  
(The dialogbox "Windows cannot open this file" opens)  

C:>
Run Code Online (Sandbox Code Playgroud)

----

对于 GUI 解决方案,我使用Creative Elements 的 PowerTools。您可以免费下载并试用 45 天。这是一组工具,您将使用他们的File Type Doctor工具来添加/编辑/删除文件类型关联。

  • 这似乎不适用于用户通过 GUI 创建的关联。 (2认同)

MDM*_*313 5

您可以在注册表中删除关联:

HKEY_CLASSES_ROOT\.cfg\ShellEx\
Run Code Online (Sandbox Code Playgroud)

并删除与写字板对应的GUID键。

  • `reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cfg` (2认同)