[RESOLVED] "Code to check if there is another instance of program running works on XP but not o
Hi All i am facing an issue with Vista.
I have logged in as administrator also but the following line is generating an exception which was working correctly earlier in XP & 2000 :(
" (Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) "
I know its due to the security features added by Vista because when I disable UAC in Vista its working perfectly.
Can anybody help me in this case
I am pasting the whole code
Public Const gsResourceNamespace As String = "NBXCAS"
If gbMultipleAppInstances(gsResourceNamespace) Then
psErrorMessage = "Not allowed to have multiple instances of: " & gsApplicationDisplayName
Call mDisplayStartupError(psErrorMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Exclamation)
End
End If
Public Function gbMultipleAppInstances(ByVal vsWindowCaption As String) As Boolean
Return (UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0)
End Function
Re: "Code to check if there is another instance of program running works on XP but not o
What's wrong with using App.PrevInstance?
Re: "Code to check if there is another instance of program running works on XP but not o
BTW: if this is VB.NET you are in the wrong forum...
Re: "Code to check if there is another instance of program running works on XP but not o
Thanks Randem,
But didnt got good response in a .Net forum so posted here if anybody know any solution ?
Regards,
Pragya
Re: "Code to check if there is another instance of program running works on XP but not o
I don't do .NET (Yet) but searching the Internet I came up with this:
Code:
Imports System.Diagnostics
Dim aModuleName As String = Diagnostics.Process.GetCurrentProcess.MainModule.ModuleName
Dim aProcName As String = System.IO.Path.GetFileNameWithoutExtension(aModuleName)
If Process.GetProcessesByName(aProcName).Length > 1 Then
Application.Exit()
End If
Re: "Code to check if there is another instance of program running works on XP but not o
Hi Randem ,
Thanks for the code ... I will give it a try once & let you know
do you work on Install Shield too ?
As your title says "Installation Specialist" I am also working in this field but i am just a beginner If I am having some install shield related doubts can I ask you that also ?
Regards,
Pragya
Re: "Code to check if there is another instance of program running works on XP but no
I can only give you theory about Install Shield, I work with ********** (Inno Script) and Inno Setup.
Well, as a beginner you may want to read this Installation Problems
Re: "Code to check if there is another instance of program running works on XP but not o
Thanks Randem,
I got the solution of my problem in a different way
Actually in Vista we need more privlidges to run this statement
so i included a manifest file and the same code is working
I reffered to following link
http://community.bartdesmet.net/blog...ng-mt.exe.aspx
Thanks,
Pragya
Thanks,
Pragya
Re: "Code to check if there is another instance of program running works on XP but not o
Actually that is a bad way to solve the issue and a security risk. You should never just use an xml file to require the full program be run as an admin.
The best way is to redesign the app depending on the amount of admin actions. If you only have a few then split the admin stuff to another exe or an activex dll etc to create another process that can be elevated. Then other other way is to recod the apps admin tasks properly so they dont need admin permissions. Like reading/writting to the registry should no longer really be needed/done. So using an xml file for your reg settings is preferred and no admin perms needed.
Re: "Code to check if there is another instance of program running works on XP but not o
As RobDog888 stated, giving more privileges is not the answer. You are suppose to give less privileges to avoid other situations. If your program REQUIRES admin privileges to run, it should be a utility not a application...
Re: "Code to check if there is another instance of program running works on XP but not o
Thanks for all your suggestions I will keep all that in my mind & try to reorganize my application ...
Regards
Pragya
Re: "Code to check if there is another instance of program running works on XP but not o
Quote:
Originally Posted by pragya
But didnt got good response in a .Net forum so posted here if anybody know any solution ?
1. That is not relevant. .NET related questions belong in .NET - Classic VB questions belong in Classic VB. Period.
2. I looked....you did not post this question in the .NET section, otherwise, I would have taken this post, and merged it with the one in .NET
Moved to VB.NET
Re: "Code to check if there is another instance of program running works on XP but not o
Hack,
I posted it on VB .Net forum I am not able to attach that link
Thanks for you suggestion I will keep this in mind :wave:
Regards
Pragya