Seems that AppMutex
directive doesn't work for my installation script.
I follow this articles: http://www.jmedved.com/2012/06/mutex-for-innosetup/
This is my C# code of my application:
private static string appGuid = "Loader";
...
bool createdNew;
var mutexSec = new MutexSecurity();
mutexSec.AddAccessRule(
new MutexAccessRule(
new SecurityIdentifier(WellKnownSidType.WorldSid, null),
MutexRights.FullControl, AccessControlType.Allow));
using (var setupMutex = new Mutex(false, @"Global\"+appGuid, out createdNew, mutexSec))
{
if (!createdNew)
{
MessageBox.Show(
"Application already running.", "Loader", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Loader(args));
}
In Inno Setup script i just have:
AppMutex=Loader
However the installer could run also if the application is running.
I also tried to check if there really was the mutex, so with process explorer I looked for application handlers and i get this:
AppMutex=Loader
Mutant \BaseNamedObjects\Loader
What I miss?
Since you've created mutex in the Global\
namespace in your application, you should explicitly do the same also for the AppMutex
mutex name in your Inno Setup script, since mutex objects are not created in global namespace if you omit namespace prefix. So using this script line should fix your problem:
[Setup]
AppMutex=Global\Loader
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With