使用Cmd.exe重新关联批处理文件

时间:2012-03-01 17:09:46

标签: batch-file windows-vista

我在windows vista上安装了gvim,非常高兴能用它来编辑所有内容。我用gvim关联.bat文件,现在我无法运行bat文件... oops !!任何人都可以解释如何使用cmd.exe重新关联.bat文件,以便双击它们会使它们刚刚运行吗?

修改 我通过删除注册表项跟随Jim的建议。重启后,bat文件仍在我的文本编辑器中打开。我仔细检查了我的注册表,并重新创建了密钥。然后我发现文本编辑器是在控制面板中设置的>默认程序>关联文件类型。我使用Cmd.exe更改了bat文件以打开,但只是打开Cmd.exe而不运行批处理文件。我猜这个问题仍在注册表中。

3 个答案:

答案 0 :(得分:8)

这包含所有默认文件扩展名的reg文件下载。只需下载bat 1并运行它,这应该将所有关联恢复为默认值。

http://www.sevenforums.com/tutorials/19449-default-file-type-associations-restore.html

注意:虽然它表示只适用于Win7,但它也适用于vista。

Default_BAT.reg copy,以防链接死亡:

Windows Registry Editor Version 5.00

; Created by: Shawn Brink
; http://www.sevenforums.com
; Tutorial: http://www.sevenforums.com/tutorials/19449-default-file-type-associations-restore.html


[-HKEY_CLASSES_ROOT\.bat]

[HKEY_CLASSES_ROOT\.bat]
@="batfile"

[HKEY_CLASSES_ROOT\.bat\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

[HKEY_CLASSES_ROOT\batfile]
@="Windows Batch File"
"EditFlags"=hex:30,04,00,00
"FriendlyTypeName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,\
  00,6f,00,6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
  32,00,5c,00,61,00,63,00,70,00,70,00,61,00,67,00,65,00,2e,00,64,00,6c,00,6c,\
  00,2c,00,2d,00,36,00,30,00,30,00,32,00,00,00

[HKEY_CLASSES_ROOT\batfile\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,69,00,6d,00,\
  61,00,67,00,65,00,72,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,36,\
  00,38,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell]
@=""

[HKEY_CLASSES_ROOT\batfile\shell\edit\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
  54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,25,00,31,00,00,\
  00

[HKEY_CLASSES_ROOT\batfile\shell\open]
"EditFlags"=hex:00,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"

[HKEY_CLASSES_ROOT\batfile\shell\print]

[HKEY_CLASSES_ROOT\batfile\shell\print\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
  54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,2f,00,70,00,20,\
  00,25,00,31,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\runas]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\batfile\shell\runas\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6d,00,\
  64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,43,00,20,00,22,00,25,00,31,00,22,\
  00,20,00,25,00,2a,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\runasuser]
@="@shell32.dll,-50944"
"Extended"=""
"SuppressionPolicyEx"="{F211AA05-D4DF-4370-A2A0-9F19C09756A7}"

[HKEY_CLASSES_ROOT\batfile\shell\runasuser\command]
"DelegateExecute"="{ea72d00e-4960-42fa-ba92-7792a7944c1d}"

[HKEY_CLASSES_ROOT\batfile\ShellEx]

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers]
@="Compatibility"

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers\Compatibility]
@="{1d27f844-3a1f-4410-85ac-14651078412d}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"

[-HKEY_CLASSES_ROOT\SystemFileAssociations\.bat]

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat]

答案 1 :(得分:4)

使用regedit.exe,查找密钥

.bat 

下的

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts 

并删除它。

编辑: 另外,这个

Windows注册表编辑器版本5.00

[HKEY_CLASSES_ROOT.bat] @ = “batfile”

[HKEY_CLASSES_ROOT.bat \ PersistentHandler] @ = “{5e941d80-bf96-11cd-b579-08002b30bfeb}”

[HKEY_CLASSES_ROOT \ batfile \壳\开放\命令] @ =“\”%1 \“%*”

来自http://social.technet.microsoft.com/Forums/en/w7itprogeneral/thread/fc2ca91d-5509-4c9b-92a5-5af19375e361

我自己不再有问题,但无论如何都抬头看上面:)!

答案 2 :(得分:0)

合并.reg文件或editing the registry manually是最可靠的选项,但也许您只需从管理员命令提示符运行assoc .bat=

如果两者都不起作用,或许Windows隐藏了您的文件扩展名,它实际上是.bat.txt文件。取消选中"隐藏已知文件类型的扩展名"在文件资源管理器选项(以前称为文件夹选项)中并重命名该文件。