1. Joined : Mar 2016
    Posts : 7
    Windows 10
       10 Oct 2016 #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 System SpecsSystem Spec


  2. Joined : Jan 2015
    UK, Midlands
    Posts : 6,233
    Win 10 Pro (1607)
       10 Oct 2016 #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 System SpecsSystem Spec


  3. Joined : Jan 2014
    Oak Ridge TN, USA
    Posts : 26,881
    Windows 10 Pro x64
       10 Oct 2016 #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 System SpecsSystem Spec


  4. Joined : Jan 2014
    Oak Ridge TN, USA
    Posts : 26,881
    Windows 10 Pro x64
       10 Oct 2016 #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 System SpecsSystem Spec


  5. Joined : Jan 2015
    UK, Midlands
    Posts : 6,233
    Win 10 Pro (1607)
       10 Oct 2016 #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 System SpecsSystem Spec


  6. Joined : Jan 2014
    Oak Ridge TN, USA
    Posts : 26,881
    Windows 10 Pro x64
       10 Oct 2016 #6

    dalchina said: View Post
    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 System SpecsSystem Spec


  7. Joined : Mar 2016
    Posts : 7
    Windows 10
       10 Oct 2016 #7

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


 


Similar Threads
Thread Forum
Solved Why Multiple explorer.exe processes running?
Win 10 Pro 64bit. From time to time I see 2 or more explorer.exe processes running (viewed via task manager). The owner of them is me. I have no idea when or why they get started. I have been taking note of the PID of the first explorer process...
General Support
how to prevent a new notepad window from opening when the file is open
This is an annoying thing to me. After I open a text file using notepad, when I double-click the text file, another notepad instance opens the file. I can edit the file at both instances making a synch problem. (Sometimes I forget that file is...
Software and Apps
Solved Prevent windows resizing when running a lower res fullscreen games
I have a laptop that has two graphics card (Intel Integrated 520 and GeForce 940M G), and not sure if it's the result of the first one, but whenever I run a new game it starts in a very low resolution. Most of the modern games support 1080p (my...
General Support
BSOD when running multiple games.
When im playing dota2, i m running marvel heroes 2015 as well, then BSOD came up, the error message was WHEA_UNCORRECTABLE_ERROR. Attached is the file needed. Not sure why the dump file cant be uploaded. If its needed please let me know. Any help is...
BSOD Crashes and Debugging
Random faults, mostly when running multiple applications
I have a dual monitor setup, so often I'll be gaming on one and watching videos or reading something on the other. The faults, which are almost never the same, only seem to occur when I'm playing some sort of game and have Firefox open. The...
BSOD Crashes and Debugging
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 16:15.
Find Us
Twitter Facebook Google+



Windows 10 Forums