Question Locked

Can I prevent users from starting an app multiple times?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Any suggestions on how to prevent users from starting the same application multiple times ona WXP system? If the app is already running, I don't want users to be able to start it again. If the app is minimized and the user double-clicks the desktop shortcut, I'd like it to do nothing or (best case) maximize the already running process.

5 replies

by cmiller5400

The only way that I can think of is to use a "starter" program that checks to see if the app is already running and if so, then focus the window and maximize it; if not, then it launches the app.

You could do this in VB.Net in a couple of minutes.

by cmiller5400

Download VB.net express edition.

Create a new windows application. Double click on the form. It should take you to a code window that states something like "private sub form1_Load byVal sender..."
"end sub"

This looks for the process "Outlook", (converts it to uppercase (ucase) and checks it to see if it is running. If it is then it activates the window.

Paste this code in the sub...

Dim plist As Process()
Dim proc As Process

plist = Process.GetProcesses

For Each proc In plist
If UCase(proc.ProcessName) = "OUTLOOK" Then
AppActivate(proc.Id)
Me.Close()
End If
Next
Shell("path to executable", AppWinStyle.MaximizedFocus, False)

by charliespencer

I found this:

http://huddledmasses.org/tag/runonlyone/

that appears to do what I want. The source code is available but I don't know what a .7z format is or how to open it.

I wasn't implying you should write an applet for me, but I appreciate your efforts. I'm not sure what's happening inside the 'If'. Are you closing the process with the 'Me.Close' and then restarting the app with the 'Shell' statement? I don't want that, I want the existing process to continue without having a new one start. (Although for all I know the app I found does the same thing; I haven't tested it yet. I'm asking for my own education and the benefit of others who may want to use your code.)

This discussion is closed to new replies.