• Login
Community
  • Login

Open file safely in Notepad++

Scheduled Pinned Locked Moved General Discussion
2 Posts 2 Posters 566 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B
    Bob Haikou
    last edited by Sep 26, 2023, 7:20 PM

    I’m sorry if this has been answered before. I couldn’t find it.

    In a batch file, I typed:

    start “C:\Program Files\Notepad++\notepad++.exe” “G:\codesamples.txt”

    In a powershell, I typed:

    start ‘C:\Program Files\Notepad++\notepad++.exe’ ‘G:\codesamples.txt’

    Notepad++ tried to execute the code in the text file! The computer went bananas. I think I tried “@ start .etc” and “start “” etc” and notepad++ still tried to execute the code.

    Is there a way to make notepad++ open a file with code safely, without running that code.

    Many thanks!

    Oh, and great software. Love it, (apart from that thing above.)

    P 1 Reply Last reply Sep 26, 2023, 7:44 PM Reply Quote 0
    • P
      PeterJones @Bob Haikou
      last edited by PeterJones Sep 26, 2023, 7:45 PM Sep 26, 2023, 7:44 PM

      @Bob-Haikou said in Open file safely in Notepad++:

      Notepad++ tried to execute the code in the text file!

      I am highly confident that it was PowerShell or START, not Notepad++, that tried to execute that text – Notepad++ does not “run” it’s command-line arguments.

      You might want to read up on the documentation of START, and make sure that it’s PowerShell compatible (since it’s really a cmd.exe command)

      You can see that it’s not Notepad++'s fault by not using the START prefix, and by running "C:\Program Files\Notepad++\notepad++.exe" "G:\codesamples.txt" from the cmd.exe prompt to run the application from the command line: it properly reads the file in Notepad++, it doesn’t try to run codesamples.txt as an executable.

      My experiments show that start-process "C:\Program Files\Notepad++\notepad++.exe" "G:\codesamples.txt" should work for you from the PowerShell command line. But that’s really a PowerShell question, not a Notepad++ question, so any further followup should be in a forum that answers PowerShell questions (ie, not here in a Notepad++ forum)

      1 Reply Last reply Reply Quote 1
      2 out of 2
      • First post
        2/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors