Prevent multiple instances of a single application from running

Posted on 2012-09-11
Last Modified: 2012-09-16
One of our users keeps opening the same application numerous times which causes him problems.  What I need is a way (program, application etc.) that will stop more than one instance of a particular, definable .exe from running and a method to prevent WIndows XP from hiding the application in the system tray.  If I can either diable the system tray auto hide feature or prevent a particular application from hiding and prevent more than one particular .exe from runningat a time, I'm in business!
Question by:icuadmin
    LVL 2

    Expert Comment

    Change the users shortcut for running the application so it points to a batch file.  In the batch file include a kill command, probably a wait command to last for 5 seconds, then a command to launch the application.  

    Then if he tries to open the application and it is already open the kill command will close it and launch a fresh instance of the application that he can see.
    LVL 1

    Accepted Solution

    I found this handy bit of VB that does the trick:

    On Error Resume Next
    strComputer = "."
    strProgramName = "notepad.exe"
    strProgramPath = "c:\windows\system32\notepad.exe"
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objShell = CreateObject("WScript.Shell")
    Set colProcessList = objWMIService.ExecQuery _
        ("Select * from Win32_Process Where Name = '" & strProgramName & "'")
    If colProcessList.Count > 0 Then
        strMessage = "Program is Already Running!"
    MsgBox strMessage
        objShell.Run strProgramPath
    End If

    And changed the icon I am interested in to never hide, job done!  Thanks for the suggestion though CPG.
    LVL 2

    Expert Comment

    So do I get any points for recommending use of a script?  That's what you've done.
    LVL 1

    Author Closing Comment

    Fixed myself.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
    Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
    The viewer will learn common shortcuts with easy ways to remember them. The viewer will then learn where to find all of the keyboard shortcuts, how to create/change them, and how to speed up their workflow.
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now