0

Every time I try to open one of my own .BAT files in Notepad++ (just to edit it, not to even run the batch file), I get the "Windows protected your PC" ... "prevented an unrecognized app from starting".

(This happens when I right-click "Edit" on the .BAT file in File Explorer. I have setup the registry to associate ".bat" and the action "Edit" with Notepad++.)

Clearly I have something configured wrong, but what?

As a developer I should be able to at least edit text files with NP++ without getting this popup all the time. And run/test my own code.

But I don't want to disable Windows Defender generally (I do worry about attacks), or have to setup a special config for every single build of every app I work on.

How?

--- Added: My Python code that installs Notepad++ and NotepadReplacer is below. Maybe this has something to do with it.

It's pretty obvious from context, but:

do(cmd) # executes cmd at Windows command line

unzip(archive, target) # unzips an archive to a target location

installed(program) # returns full path to executable

def installNotepadPlusPlus():  
    """Notepad++"""
    
    do('choco install notepadplusplus -y')

    with open(t.BinPath + r'\edit.bat', "w") as ed:
        ed.write(r'@start /b "" "' + 'notepad++' + r'" %1 %2 %3 %4 %5 %6 %7 %8 %9')
       
    notepadPlusPlus_exePath = installed(t.NotepadPlusPlus_exeSubPath)

    unzip(r'auto_install\Notepad++_ROAMING.7z', os.environ[r'appdata'] + r'\Notepad++')

    # This replaces MS's notepad.exe (so makes all text files default to the new text editor)
    do(r'auto_install\NotepadReplacerSetup-1.5.exe /NOTEPAD="' + notepadPlusPlus_exePath + r'" /SILENT')

    # Notepad++ for editing text files (esp .log files)
    do(r'ftype txtfile="' + notepadPlusPlus_exePath + r'" "%%1"')

    # Make files without any extension open in Notepad++
    do(r'assoc .="(none)"')
    do(r'ftype "(none)"="' + notepadPlusPlus_exePath + r'" "%%1"')
    do(r'assoc "(none)"\DefaultIcon=%SystemRoot%\System32\imageres.dll,-102') # use text file icon
nerdfever.com
  • 1,652
  • 1
  • 20
  • 41
  • Easiest way is to rename it to .txt during development. Also can try "Run as Administrator" with the .bat file (set up a shortcut pointing to the .bat file and configure it to Run as Admin) – edtheprogrammerguy Oct 07 '22 at 17:15
  • @edtheprogrammerguy That's even more work than dealing with the popup each time. – nerdfever.com Oct 07 '22 at 17:31

0 Answers0