Question

Locked

Can I prevent users from starting an app multiple times?

By CharlieSpencer ·
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.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

The only way that I can think of is...

by cmiller5400 In reply to Can I prevent users from ...

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.

Collapse -

I probably could,

by CharlieSpencer In reply to The only way that I can t ...

if I knew jack-squat about VB.Net, or VB, or .Net :-)

Collapse -

Okay then...

by cmiller5400 In reply to I probably could,

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)

Collapse -

Thanks, but in the meantime

by CharlieSpencer In reply to Okay then...

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.)

Back to Windows Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums