Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

HOW TO DISABLE THE EXECUTION OF APPLICATION IF IT IS RUNNING.

Hi,

I am working on VB.NET application. I need to disable the execution of the application if any one is running the same. i.e we can use multiple instances of the same application in windows. I need to prevent such type of access.

Anybody knows how to do, plz help me.

Venkatesh

Comments

  • larryjflarryjf Member Posts: 1
    : Hi,
    :
    : I am working on VB.NET application. I need to disable the execution of the application if any one is running the same. i.e we can use multiple instances of the same application in windows. I need to prevent such type of access.
    :
    : Anybody knows how to do, plz help me.
    :
    : Venkatesh
    :

    When your application starts up you must check currently running processes to see if your application is already running.
    The System.Diagnostics.Process allows you to look at currently running processes.

    You might want to do something like this...

    Public Sub Main()

    Dim Proc() As Process
    Dim ModuleName, ProcName As String
    ModuleName = Process.GetCurrentProcess.MainModule.ModuleName
    ProcName = System.IO.Path.GetFileNameWithoutExtension(ModuleName)
    Proc = Process.GetProcessesByName(ProcName)
    If Proc.Length > 1 Then ''application already running
    Application.Exit() ''or something similar
    End If

    End Sub
  • vrao_nvrao_n Member Posts: 12
    : : Hi,
    : :
    : : I am working on VB.NET application. I need to disable the execution of the application if any one is running the same. i.e we can use multiple instances of the same application in windows. I need to prevent such type of access.
    : :
    : : Anybody knows how to do, plz help me.
    : :
    : : Venkatesh
    : :
    :
    : When your application starts up you must check currently running processes to see if your application is already running.
    : The System.Diagnostics.Process allows you to look at currently running processes.
    :
    : You might want to do something like this...
    :
    : Public Sub Main()
    :
    : Dim Proc() As Process
    : Dim ModuleName, ProcName As String
    : ModuleName = Process.GetCurrentProcess.MainModule.ModuleName
    : ProcName = System.IO.Path.GetFileNameWithoutExtension(ModuleName)
    : Proc = Process.GetProcessesByName(ProcName)
    : If Proc.Length > 1 Then ''application already running
    : Application.Exit() ''or something similar
    : End If
    :
    : End Sub
    :

    Thank You so much, now I am able to disable the execution with the help of code similar to above.

    Once again thank you!
    If u dont mind may I know who solved this?

Sign In or Register to comment.