WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: pguild on April 19, 2024, 06:47:35 PM

Title: duplicate .txt file opened. Why? How can I fix this?
Post by: pguild on April 19, 2024, 06:47:35 PM
I give a simple command like

Run("Notepad",filename)
Note that filename is a valid file with a ".txt" extension in the current directory.

Notepad runs but two copies of the file appear. Why? How do I fix this?
Before running that command I check to make sue that the filename does not exist
with:
If WinExist(filename) == @FALSE
   Run("Noteopad",filename)
Endif
Title: Re: duplicate .txt file opened. Why? How can I fix this?
Post by: td on April 20, 2024, 09:11:22 AM
MSFT has been updating Notepad.exe with multiple "enhancements" since it was rewritten as a UWP application. The answer to your "how to fix it" question likely depends on how current your version of Notepad is. On my system, I have the settings option (the gear graphic on the right-hand side of the menu bar) When Notepad starts set to Open new window. This causes a new instance of Notepad to start with a single tabbed window.  If I set it to Open content from previous session, I get a single instance of Notepad with 2 open table windows. Notepad also has the option Opening files. That can be set to Open in new tab or Open in new window.

You might see how some combinations of the above options could produce the effect you are witnessing. But as mentioned how that all plays out may depend on how up-to-date your version of Notepad is.
Title: Re: duplicate .txt file opened. Why? How can I fix this?
Post by: pguild on April 20, 2024, 10:00:43 AM
Thanks Winbatch Tech Support! Setting Notepad to "Open in new tab" worked well.