Unable to EDIT a batch file.

I am suddenly unable to edit batch files on my computer.  If I change the file extension to ".txt" I can edit the file and rename it to ".bat".  However, if the file has the ".bat" file extension I get an "access denied" error whether I try to run the batch file or try to edit the batch file.  

Even if I create a new file, enter some commands, and then save the file as a batch file, I am subsequently unable to Open or Edit the file, even though it is a file I just finished creating.
Gary Connor, Phd.CIO, CISOAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dustin99352Commented:
Right click the batch file and go to properties.  Then go to the security tab and make sure you have full control over the file.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Is there some AntiVirus software running? It might try to act on .bat and .cmd, holding them locked for scanning, or blocking access completely.
Gary Connor, Phd.CIO, CISOAuthor Commented:
Yes, I have "Full Control" access to the file (thus I am able to create and edit it as a .txt file).

We have Symantec Endpoint Protection running on all machines, with a centralized policy server.  My machine is the only one upon which I am unable to even edit a batch file.  If I disable Symantec Endpoint Protection I still get an "access denied" on the file if it is named *.bat, but have no problems editing it when I change the extension.
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Gary Connor, Phd.CIO, CISOAuthor Commented:
My research throughout the day leads me to believe this is some sort of registry problem, but I can't find anything more specific.
OrcbighterCommented:
What type association do you have on .bat files?
right-click on file, select properties, general tab.
entry for "type of file"?

Gary Connor, Phd.CIO, CISOAuthor Commented:
"MS-DOS Batch File" (no quotes)
Bill PrewIT / Software Engineering ConsultantCommented:
I agree with Qlemo, sounds like some kind of malware protecting software on the PC may be restricting access to BAT files.

One question, do you have the same problem with CMD extension files?  

How about say VBS extension files?

Also, could you run the following two cmmands at a command prompt and copy up the output here?

assoc .bat
ftype batfile

Have you tried running the BAT file from a command shell window, or only from Explorer?

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
C:\Documents and Settings\gary>assoc bat
File association not found for extension bat

C:\Documents and Settings\gary>ftype batfile
batfile="%1" %*


Checking on cmd and vbs now...
Gary Connor, Phd.CIO, CISOAuthor Commented:
No problems with .cmd or .vbs files - I can edit and execute both.
SuperdaveCommented:
Does it give the error when you Run "notepad thefile.bat" or just if you "Edit" it in from Windows Explorer?  If the latter, then it would be the way the Edit verb is registered to .bat file type.
Bill PrewIT / Software Engineering ConsultantCommented:
==> gary_connor:

==> C:\Documents and Settings\gary>assoc bat
==> File association not found for extension bat

You forgot the period before the BAT, please repeat as:

assoc .bat

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
If I run ""notepad thefile.bat" or open notepad and open the file from within NotePad there is no problem.  Since your obviously thinking in the right direction, I tried and found that I ca directly execute the bat file from a command prompt.

It seems that both the open and the edit problems only occur in explorer.
Gary Connor, Phd.CIO, CISOAuthor Commented:
..also (sorry, I missed this one before):

C:\Documents and Settings\gary>assoc.bat
.bat=batfile
Gary Connor, Phd.CIO, CISOAuthor Commented:
... and I suppose only Batman can use batfiles?
Bill PrewIT / Software Engineering ConsultantCommented:
Okay, basic association seems correct.

What version of Windows are you running?

~bp
Bill PrewIT / Software Engineering ConsultantCommented:
:-) I like that one!
Gary Connor, Phd.CIO, CISOAuthor Commented:
Windows XP with SP3.
Bill PrewIT / Software Engineering ConsultantCommented:
So, in Windows Explorer, if you do Tools, Folder Options, File Type, is there an entry for BAT files in the list?

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
NO :- (
Bill PrewIT / Software Engineering ConsultantCommented:
That's actually right, it shouldn't be in there.

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
My wife just said to tell you that "changing the spark plugs" always works.

Bill PrewIT / Software Engineering ConsultantCommented:
Ha, not now adays, plugs last a long time now...

Bill PrewIT / Software Engineering ConsultantCommented:
Okay, you might want to grab the NirSoft utility at this page and run it, seeing if it shows info for BAT files.

http://www.nirsoft.net/utils/file_types_manager.html

There's no installation for this, just extract the files from the zip to a folder and run the EXE.

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
For .bat files it shows:

edit    edit    No    No    3/26/2009 4:17:39 PM    %SystemRoot%\System32\NOTEPAD.EXE %1
open    open    No    No    3/26/2009 4:17:39 PM    "%1" %*
print    print    No    No    3/26/2009 4:17:39 PM    %SystemRoot%\System32\NOTEPAD.EXE /p %1
Bill PrewIT / Software Engineering ConsultantCommented:
Here's what it looks like on one of my XP systems here for the BAT extension, see if it matches yours, or you see any clues.

~bp
bat.htm
Bill PrewIT / Software Engineering ConsultantCommented:
Hmmm, that seems reasonable...

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
Those results are attached to this submission as an image:

Snap1.jpg
Gary Connor, Phd.CIO, CISOAuthor Commented:
They look identical to me.
Bill PrewIT / Software Engineering ConsultantCommented:
How about in the top section, does it look something like this?

.bat      batfile      MS-DOS Batch File      0x00000430      0x00000000      %SystemRoot%\System32\shell32.dll,-153      11/16/2006 8:57:02 PM      Standard      Microsoft® Windows® Operating System      6.00.2900.5622 (xpsp_sp3_gdr.080617-1319)      Windows Shell Common Dll      Microsoft Corporation      

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
Our icon IDs are are different, but otherwise everything is identical.
Gary Connor, Phd.CIO, CISOAuthor Commented:
.bat    batfile    MS-DOS Batch File                    *    0x00000430    0x00000008    C:\WINDOWS\system32\shell32.dll,71    3/26/2009 4:17:38 PM    Standard        Microsoft® Windows® Operating System    6.00.2900.5622 (xpsp_sp3_gdr.080617-1319)    Windows Shell Common Dll    Microsoft Corporation    


Gary Connor, Phd.CIO, CISOAuthor Commented:
The asterik in mine is under the column heading "Always Show Extension."
Gary Connor, Phd.CIO, CISOAuthor Commented:
Under "Browser flags" mine has "0x00000008" while yours has "0x00000000"
Bill PrewIT / Software Engineering ConsultantCommented:
Well, that all seems to jive with a working system.  

The fact that you can edit it from notepad directly, and run it from a command prompt seems to point away from an anti-virus program blocking it.  Seems to point more toward the way Windows Explorer is handling that file extension, but we have checked the obvious stuff there.

Hmmmm...

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
Having changed the Browser Flags to match yours I can now execute the file from explorer, I simply can't right-click and choose "Edit."  I can open notepad and open the file from within notepad.

Half my problems solved - with a work-around for the right-click to edit.
Bill PrewIT / Software Engineering ConsultantCommented:
Well, that's encouraging.  I was looking for docs on the bits in the browser flags, but hadn't found a reference for them yet.

~bp
Bill PrewIT / Software Engineering ConsultantCommented:
If you right click, in the pop up menu is there an "edit with..." or "open with..." option, or just "edit"?

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
Interestingly enough, If I right-click choose "Edit" I get the access denied, but if I right-click and choose a text editor everything works fine.  While there is clearly a problem with my system, I would probably call this one solved, especially considering the category within which it is posted.
Bill PrewIT / Software Engineering ConsultantCommented:
I found this on the EditFlags, but yours and mine seem to match 0430, so not sure this is the problem...

~bp
Bill PrewIT / Software Engineering ConsultantCommented:
OrcbighterCommented:
If you have no program accociated with the .bat  filytype, how are you getting the "edit" option? You should be getting only "edit with..."

Gary Connor, Phd.CIO, CISOAuthor Commented:
So, it appears to me that everything works, but that the right click "Edit" command must pass in a parameter to a non-existent program (which is easy to work around)
Bill PrewIT / Software Engineering ConsultantCommented:
Here's the related REG entry, in case you want to compare it...

~bp
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\batfile]
@="MS-DOS Batch File"
"EditFlags"=hex:30,04,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,73,00,68,00,\
  65,00,6c,00,6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,31,00,35,\
  00,33,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell]

[HKEY_CLASSES_ROOT\batfile\shell\edit]

[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\shellex]

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

[HKEY_CLASSES_ROOT\batfile\shellex\PropertySheetHandlers]

[HKEY_CLASSES_ROOT\batfile\shellex\PropertySheetHandlers\PifProps]
@="{86F19A00-42A0-1069-A2E9-08002B30309D}"

[HKEY_CLASSES_ROOT\batfile\shellex\PropertySheetHandlers\ShimLayer Property Page]
@="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gary Connor, Phd.CIO, CISOAuthor Commented:
I don't know, but that is what appears:

Snap2.jpg
Gary Connor, Phd.CIO, CISOAuthor Commented:
"She Who Rules" calls me to dinner - I will compare registry entries and see if I can fix things - will post again tomorrow morning, and mark this solved either way.
Bill PrewIT / Software Engineering ConsultantCommented:
One other long shot. In the registry, make sure there isn't a .BAT under:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts

if there is, remove it.

~bp
Bill PrewIT / Software Engineering ConsultantCommented:
Okay, enjoy eats, and good luck!

~bp
Gary Connor, Phd.CIO, CISOAuthor Commented:
Can't thank you enough - I made a little .reg file from the info you sent, entered it, and now everything works perfectly!  You should be a GURU.  Seriously, thank you.
Gary Connor, Phd.CIO, CISOAuthor Commented:
Great at logically stepping me through the issues involved to find exactly what the problem was, and then showing me explicitly how to fix it.  What a GREAT experience.  If only more tech support was like this !
Bill PrewIT / Software Engineering ConsultantCommented:
Excellent, pleasant response on this question this morning, brightened my day to see you had the problem resolved.

Thanks much for the glowing comments in the accepted solution too, while those aren't publicly visible I appreciate the kind words, and I'm glad we were able to work it to a solution.

~bp
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.