Batch files don't run - they're being open

2020-02-23 06:20发布

I use WinXP sp3, and I have created a .bat file that does something. When I double click on it, a Notepad is opened and I can edit the batch file - but it is not run ??!?!

I expect that when I double click a .bat file - it should run, no? How can I fix this?

16条回答
The star\"
2楼-- · 2020-02-23 06:24

Check if you have this key in your registry :

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat\UserChoice

if you have one it means that the .bat extension is currently associated with notepad (or another program defined by the "Progid" key under this node).

Backup you registry and remove this .bat "UserChoice" node.

your .bat files should then run normally.

查看更多
Lonely孤独者°
3楼-- · 2020-02-23 06:24

Windows 7 does that crap all the time.

Best to keep a handy-dandy lil .reg file around to fix it - easier and simpler than having to go edit the registry every time.

Copy this - paste in notepad - give it a filename you can remember so you'll know what it does and what it's for, and when you paste it into notepad, make sure you don't have any extra spaces or carriage-returns. doesn't 'always' affect it, but i've seen it fewk up on people a time er two:

----------everything below this line - do not include this line----------

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\OpenWithList]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\OpenWithProgids]
"batfile"=hex(0):
查看更多
我想做一个坏孩纸
4楼-- · 2020-02-23 06:26

Check to be sure it is an executable file under the properties security tab.

查看更多
再贱就再见
5楼-- · 2020-02-23 06:28

Another common mistake is to have "hide extensions of known file types" set, meaning that although the file name says

"----.bat"

it is really

"-----.bat.txt".

You need to go into "Folder Options --> View Options" to untick this.

查看更多
啃猪蹄的小仙女
6楼-- · 2020-02-23 06:30

Save the following code as a .REG file, by adding the following code in a new text document.
Don't forget to remove the .txt when you save it!
Right-click and Merge the new .REG file.
That's all! Tested & working:

 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] 
查看更多
爱情/是我丢掉的垃圾
7楼-- · 2020-02-23 06:32

I was struggling from the last two days, i have gone through the many post and almost every where telling the same thing go through the below and delete the file
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.bat\UserChoice, but in my Registry i could not Find out the FileExts then finally i got the solution. click on the below link http://www.sevenforums.com/tutorials/19449-default-file-type-associations-restore.html select the BAT Option click the bat link, exe will be download run the downloaded exe. Restart the system it will work fine.

查看更多
登录 后发表回答