?
Solved

Prevent multiple instances of a single application from running

Posted on 2012-09-11
4
Medium Priority
?
2,160 Views
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!
0
Comment
Question by:icuadmin
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:-CPG-
ID: 38385972
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.
0
 
LVL 1

Accepted Solution

by:
icuadmin earned 0 total points
ID: 38389992
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
Else
    objShell.Run strProgramPath
End If

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

Expert Comment

by:-CPG-
ID: 38389997
So do I get any points for recommending use of a script?  That's what you've done.
0
 
LVL 1

Author Closing Comment

by:icuadmin
ID: 38402970
Fixed myself.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today’s time where quality is an essential factor all over the world, software testing and effective QA (Quality Assurance) is an all-important element for any business to ensure less risk for an end product. A good software testing company deliv…
This tutorial is intended to teach the basics of 3-D Modeling using TinkerCad.com as the Computer Aided Drafting software. Once complete this model can be 3D printed.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
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…

621 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