Microsoft added a pretty cool Subroutine in Visual Basic 2005 under the System.Windows.Forms namespace in the Application class called: “Restart()” All you have to do is run that sub-routine in your code when you want the application to restart. Just simply run like below:
Microsoft actually added an application Pre-Instance feature in version 2005 of VB. It is also available in VB.NET 2008 and Visual Basic 2010. You no longer have to use code to do so like you did in the original versions of .NET.
You can enable it like below…
Go to the Project menu, click Properties, click the Application tab and below the: Windows Application Framework Properties groupbox you will see a checkbox named: Make Single Instance Application. You simply checkmark that box and it will not allow your application to contain more than 1 loaded instance at a time.
Well that’s it. When your application loads and it detects a clone, it will continue to open your application and close the previous instance. Have fun!