I'm using Process.Start() to initialize an elevated copy of the currently running application. Unfortunately Process.Start() returns null because it thinks it's using an existing process of my application, and while there is an existing process, it doesn't specify any way of handling this kind of entry point.
Is there any way in .NET (via configuration or otherwise) that I can tell the system not to reuse existing copies of my process? This issue only seems to occur on Windows XP, and not Vista or 7.
A copy of the code is below:
internal static bool EnsureAssociation()
{
// Check to make sure RoketPack is associated.
if (!Protocol.IsAssociated())
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = UNC.UniversalApplicationPath;
info.UseShellExecute = true;
if (!UAC.IsAdmin())
info.Verb = "runas"; // Provides Run as Administrator
info.Arguments = "--associate";
Process proc = null;
try
{
proc = Process.Start(info);
}
catch (Win32Exception)
{
Errors.Raise(Errors.ErrorType.ERROR_CAN_NOT_ASSOCIATE_PROTOCOL);
return false;
}
if (null != proc)
{
// Wait until the association is complete.
proc.WaitForExit();
return Protocol.IsAssociated();
}
else
{
Errors.Raise(Errors.ErrorType.ERROR_CAN_NOT_ASSOCIATE_PROTOCOL);
return false;
}
}
else
return true;
}