Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Check Instance Of Application

Posted on May 9, 2014October 26, 2015 By David Kittell

Preferred Method:
Project Menu -> Properties -> Application -> Check Box: Make Single Instance Application

Non-Preferred Method:
This code will look in your task manager for the same name of your application, if it exists it will prevent another copy of it from running.

' Make sure they only have one instance of the application Open - Start
Private Sub CheckInstanceOfApp()
     Dim appProc() As Process
     Dim strModName, strProcName As String
     strModName = Process.GetCurrentProcess.MainModule.ModuleName
     strProcName = System.IO.Path.GetFileNameWithoutExtension(strModName)

     appProc = Process.GetProcessesByName(strProcName)
     If appProc.Length > 1 Then
          MessageBox.Show("There is an instance of this application running.", Application.ProductName)
          Application.Exit()
     Else
          'MessageBox.Show("There are no other instances running.", Application.ProductName)
     End If
End Sub
' Make sure they only have one instance of the application Open - Stop
Originally Posted on May 9, 2014
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code VB.NET

Post navigation

Previous post
Next post

Related Posts

PowerShell – Get Computer Information

Posted on November 6, 2015November 10, 2015

This script is pieced together from various posts, I only take credit for combining the resources. There is more than initially is seen to this script, based on the code below it will write a text file on c:\ and does need admin privileges in order to run. Right around…

Read More

User Registration – Check Username Availability

Posted on July 21, 2014October 26, 2015

This is a simple example of how to check for the existence of a username prior to letting someone select a username. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserRegistration.aspx.cs" Inherits="UserRegistration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>User Registration – Check Username Availability</title> </head> <body> <form…

Read More

UNIX Terminal – Clear Bash History

Posted on October 28, 2015

history -cw All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes