By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,092 Members | 1,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,092 IT Pros & Developers. It's quick & easy.

Running multiple instances of a program

P: n/a
I just finished a WinForms app in VB.NET. I want to allow the user to be
able to run multiple instances of the program like you can with Notepad and
Wordpad. The way it is now, once I run the executable I can not run another
instance as long as the first instance is running. How can I change this
behavior? Thanks.
Nov 20 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
* "Clark Stevens" <cy*********@hotmail.com> scripsit:
I just finished a WinForms app in VB.NET. I want to allow the user to be
able to run multiple instances of the program like you can with Notepad and
Wordpad. The way it is now, once I run the executable I can not run another
instance as long as the first instance is running. How can I change this
behavior?


What you want to do is the default behavior. Preventing the application
from running more than once would require additional code.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #2

P: n/a
Clark,

The default is to allow you to run as many instances as you want.

Create a small test project with 1 form. Run the project in Visual Studio
so the bin directory is created and the .exe is built.

Exit Visual Studio and navigate to the projects bin directory.

Double-Click the .exe and observe the form displays.

Double-Click the .exe again and observe a second form displays.

....

-Sam Matzen
"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:yE*******************@twister.nyroc.rr.com...
I just finished a WinForms app in VB.NET. I want to allow the user to be
able to run multiple instances of the program like you can with Notepad and Wordpad. The way it is now, once I run the executable I can not run another instance as long as the first instance is running. How can I change this
behavior? Thanks.

Nov 20 '05 #3

P: n/a
"Samuel L Matzen" <sm*****@slm.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Clark,

The default is to allow you to run as many instances as you want.

Create a small test project with 1 form. Run the project in Visual Studio
so the bin directory is created and the .exe is built.

Exit Visual Studio and navigate to the projects bin directory.

Double-Click the .exe and observe the form displays.

Double-Click the .exe again and observe a second form displays.


Okay, I did this and it does run multiple instances. However, I have setup
a shortcut on the desktop which launches the executable in the program's Bin
directory. It is the shortcut that doesn't seem to allow the multiple
instances. Every time I launch the shortcut it doesn't run another instance
of the executable. Is there some settings on the shortcut that I need to
change or something?
Nov 20 '05 #4

P: n/a
Clark,

I just created a shortcut and it creates multiple instances.

I can't find anything about a shortcut that would make the application not
launch multiple times.

-Sam Matzen
"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:cw*******************@twister.nyroc.rr.com...
"Samuel L Matzen" <sm*****@slm.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Clark,

The default is to allow you to run as many instances as you want.

Create a small test project with 1 form. Run the project in Visual Studio so the bin directory is created and the .exe is built.

Exit Visual Studio and navigate to the projects bin directory.

Double-Click the .exe and observe the form displays.

Double-Click the .exe again and observe a second form displays.
Okay, I did this and it does run multiple instances. However, I have

setup a shortcut on the desktop which launches the executable in the program's Bin directory. It is the shortcut that doesn't seem to allow the multiple
instances. Every time I launch the shortcut it doesn't run another instance of the executable. Is there some settings on the shortcut that I need to
change or something?

Nov 20 '05 #5

P: n/a

"Samuel L Matzen" <sm*****@slm.com> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...
Clark,

I just created a shortcut and it creates multiple instances.

I can't find anything about a shortcut that would make the application not
launch multiple times.


I figured out what is causing this. I have a keyboard shortcut defined for
the shortcut on the desktop. When I press the corresponding keyboard
shortcut it launches the executable as expected. However, when I press the
keyboard shortcut a second time it will not launch again. I can launch
another instance by going to the desktop and double clicking on the
shortcut, but pressing the assigned keyboard shortcut multiple times will
not work. Can you duplicate this?
Nov 20 '05 #6

P: n/a
Clark,

* "Clark Stevens" <cy*********@hotmail.com> scripsit:
I just created a shortcut and it creates multiple instances.

I can't find anything about a shortcut that would make the application not
launch multiple times.


I figured out what is causing this. I have a keyboard shortcut defined for
the shortcut on the desktop. When I press the corresponding keyboard
shortcut it launches the executable as expected. However, when I press the
keyboard shortcut a second time it will not launch again. I can launch
another instance by going to the desktop and double clicking on the
shortcut, but pressing the assigned keyboard shortcut multiple times will
not work. Can you duplicate this?


I am able to duplicate this and I think this behavior is "by design".
If the application is not yet started and you press the keyboard
shortcut assigned to the shell link pointing to the application, the
application will be started. If the application is already running and
the shortcut is pressed, the running instance is activated. That's what
the help popup for the shortcut field in the shell link's properties
dialog box is saying.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #7

P: n/a
Clark,

Yes, I have observed the behavior you described. You apparently cannot
launch multiple instances with the shortcut key.

-Sam Matzen
"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:4U*******************@twister.nyroc.rr.com...

"Samuel L Matzen" <sm*****@slm.com> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...
Clark,

I just created a shortcut and it creates multiple instances.

I can't find anything about a shortcut that would make the application not launch multiple times.
I figured out what is causing this. I have a keyboard shortcut defined

for the shortcut on the desktop. When I press the corresponding keyboard
shortcut it launches the executable as expected. However, when I press the keyboard shortcut a second time it will not launch again. I can launch
another instance by going to the desktop and double clicking on the
shortcut, but pressing the assigned keyboard shortcut multiple times will
not work. Can you duplicate this?

Nov 20 '05 #8

P: n/a
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ui**************@tk2msftngp13.phx.gbl...
I am able to duplicate this and I think this behavior is "by design".
If the application is not yet started and you press the keyboard
shortcut assigned to the shell link pointing to the application, the
application will be started. If the application is already running and
the shortcut is pressed, the running instance is activated. That's what
the help popup for the shortcut field in the shell link's properties
dialog box is saying.


Got it. So I guess there's no way to directly load multiple instances of
the same app using a shortcut key. Hmmm, I really need this capability, so
I'll have to figure something else out. Well, anyway, thanks for your help.
I appreciate it.
Nov 20 '05 #9

P: n/a
Create a .CMD script with the following lines in it and associate the
shortcut and shortcut key to your script:

start "path\myapp.exe"
exit

Now your application will be indirectly started each time you press the
shortcut key.

Mike Ober.

"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:BH*******************@twister.nyroc.rr.com...
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ui**************@tk2msftngp13.phx.gbl...
I am able to duplicate this and I think this behavior is "by design".
If the application is not yet started and you press the keyboard
shortcut assigned to the shell link pointing to the application, the
application will be started. If the application is already running and
the shortcut is pressed, the running instance is activated. That's what
the help popup for the shortcut field in the shell link's properties
dialog box is saying.
Got it. So I guess there's no way to directly load multiple instances of
the same app using a shortcut key. Hmmm, I really need this capability,

so I'll have to figure something else out. Well, anyway, thanks for your help. I appreciate it.

Nov 20 '05 #10

P: n/a
"Samuel L Matzen" <sm*****@slm.com> wrote in message
news:eU**************@tk2msftngp13.phx.gbl...
Clark,

Yes, I have observed the behavior you described. You apparently cannot
launch multiple instances with the shortcut key.

-Sam Matzen


I use keyboard shortcuts quite a bit, and was always annoyed by my Internet
Explorer always opening a new window instead of switching to the existing
one when I used the shortcut.

Using XP, I can assign a keyboard shortcut to IE in my start menu, or to a
shortcut on a desktop, and it always opens a new instance. Doing the same
with a VB.NET program always switches to the open application instance.

Seems that MS is able to do it for themselves, at least. :-)

Best Regards,

Andy
Nov 20 '05 #11

P: n/a

"Andy Becker" <x@x.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Using XP, I can assign a keyboard shortcut to IE in my start menu, or to a
shortcut on a desktop, and it always opens a new instance. Doing the same
with a VB.NET program always switches to the open application instance.


More info... The same experiment with Firefox instead of IE has it acting
the same as a VB.NET application, i.e. only one instance is opened.
Sumpin's up with IE, methinks.

Best Regards,

Andy
Nov 20 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.