|
-
Oct 5th, 2007, 01:36 AM
#1
Thread Starter
Junior Member
[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
-
Oct 5th, 2007, 01:42 AM
#2
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?
-
Oct 5th, 2007, 01:47 AM
#3
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...
-
Oct 5th, 2007, 01:59 AM
#4
Thread Starter
Junior Member
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
-
Oct 5th, 2007, 02:03 AM
#5
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
-
Oct 5th, 2007, 02:11 AM
#6
Thread Starter
Junior Member
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
-
Oct 5th, 2007, 02:45 AM
#7
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
Last edited by randem; Oct 5th, 2007 at 02:49 AM.
-
Oct 8th, 2007, 04:25 AM
#8
Thread Starter
Junior Member
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
-
Oct 8th, 2007, 11:53 AM
#9
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 8th, 2007, 12:59 PM
#10
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...
-
Oct 9th, 2007, 12:43 AM
#11
Thread Starter
Junior Member
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
-
Oct 9th, 2007, 12:44 PM
#12
Re: "Code to check if there is another instance of program running works on XP but not o
 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
-
Oct 10th, 2007, 01:19 AM
#13
Thread Starter
Junior Member
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
Regards
Pragya
Last edited by pragya; Oct 10th, 2007 at 01:28 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|