How do I prevent multiple .exes (eg notepad) from running?


  1. Posts : 52
    Windows 10
       #1

    How do I prevent multiple .exes (eg notepad) from running?


    I sometimes accidentally run two copies of notepad. Sometimes, I don't spot them both in my taskbar. I wondered if there was a way to alert me that I'm attempting to run the same .exe, if I already have it open?

    For example, on my desktop I have a notepad file. I'll run that, but sometime later, I'll double click on it again, forgetting that I've already got the same file open in notepad for editing, because it's been minimised, and I don't check the taskbar to see if it's there. Thanks for any comments.
      My Computer


  2. Posts : 42,953
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2

    Hi, you could, if you wished, write a small script that launches Notepad from a shortcut

    The sequence would be

    If Notepad.exe already exists
    Ask if you wish to continue
    If yes, open Notepad
    else exit

    Quite easy in Autohotkey for example (free).
      My Computers


  3. Posts : 22,740
    Windows 10 Home x64
       #3

    I just did a quick Google search and this is what I found:
    How to check if a process is running via a batch script
    windows - How to check if a process is running via a batch script - Stack Overflow

    And here's the code that's posted that looks interesting and it's set up for Notepad. So there might not be much adjustments required to it.
    Note: It's the second answer in the thread.. I'll check it out ASAP.

    Code:
    PHP Code:
    tasklist /FI "IMAGENAME eq notepad.exe" /FO CSV search.log

    FOR /%%A IN (search.log) DO IF %%~zA EQU 0 GOTO end

    start notepad
    .exe

    :end

    del search
    .log 
      My Computer


  4. Posts : 22,740
    Windows 10 Home x64
       #4

    Oh well.. that may not cut it.. I'll do some coding and see what I can come up with. I might have found a solution but it's going to take a bit of testing. With luck I'll have some solid results today.
      My Computer


  5. Posts : 42,953
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #5

    Hi, here you are.. just install Autohotkey, and run the ahk script.

    Notepad.zip

    or simply run the exe file.

    As you have the AHK file you can edit that as you wish. Install Autohotkey and you can compile it with 1 click.
      My Computers


  6. Posts : 22,740
    Windows 10 Home x64
       #6

    dalchina said:
    Hi, here you are.. just install Autohotkey, and run the ahk script.

    Notepad.zip

    or simply run the exe file.

    As you have the AHK file you can edit that as you wish. Install Autohotkey and you can compile it with 1 click.
    Nice.. that's better than the code I was playing with for certain.
    Jeff
      My Computer


  7. Posts : 52
    Windows 10
    Thread Starter
       #7

    Thank you, that's much appreciated. I have marked this thread as solved.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 23:01.
Find Us




Windows 10 Forums