mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-11-28 18:41:04 +00:00
parent
dcdf79dc3a
commit
d214a8d749
|
|
@ -12,7 +12,7 @@ namespace WelsonJS.Launcher
|
||||||
{
|
{
|
||||||
private string workingDirectory;
|
private string workingDirectory;
|
||||||
private string instanceId;
|
private string instanceId;
|
||||||
private string entryFileName;
|
private readonly string entryFileName;
|
||||||
private string scriptName;
|
private string scriptName;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
|
|
@ -23,7 +23,7 @@ namespace WelsonJS.Launcher
|
||||||
|
|
||||||
if (IsInAdministrator())
|
if (IsInAdministrator())
|
||||||
{
|
{
|
||||||
Text = Text + " (Administrator)";
|
Text += " (Administrator)";
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyIcon1.DoubleClick += OnShow;
|
notifyIcon1.DoubleClick += OnShow;
|
||||||
|
|
@ -109,8 +109,10 @@ namespace WelsonJS.Launcher
|
||||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
string filePath = openFileDialog.FileName;
|
string filePath = openFileDialog.FileName;
|
||||||
ExtractAndRun(filePath);
|
Task.Run(() => ExtractAndRun(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisableUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,17 +122,15 @@ namespace WelsonJS.Launcher
|
||||||
workingDirectory = Program.GetWorkingDirectory(instanceId);
|
workingDirectory = Program.GetWorkingDirectory(instanceId);
|
||||||
scriptName = txtUseSpecificScript.Text;
|
scriptName = txtUseSpecificScript.Text;
|
||||||
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// If exists, delete all
|
// try to validate GUID
|
||||||
if (Directory.Exists(workingDirectory))
|
if (Directory.Exists(workingDirectory))
|
||||||
{
|
{
|
||||||
Directory.Delete(workingDirectory, true);
|
throw new InvalidOperationException("GUID validation failed. Directory already exists.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to extact ZIP file
|
// try to extract ZIP file
|
||||||
ZipFile.ExtractToDirectory(filePath, workingDirectory);
|
ZipFile.ExtractToDirectory(filePath, workingDirectory);
|
||||||
|
|
||||||
// record the first deploy time
|
// record the first deploy time
|
||||||
|
|
@ -144,19 +144,11 @@ namespace WelsonJS.Launcher
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
SafeInvoke(() =>
|
SafeInvoke(() => MessageBox.Show($"Extraction failed: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error));
|
||||||
{
|
|
||||||
MessageBox.Show("Error: " + ex.Message);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable UI
|
// Enable UI
|
||||||
SafeInvoke(() => {
|
SafeInvoke(() => EnableUI());
|
||||||
EnableUI();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
DisableUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RecordFirstDeployTime(string directory)
|
private void RecordFirstDeployTime(string directory)
|
||||||
|
|
@ -181,8 +173,9 @@ namespace WelsonJS.Launcher
|
||||||
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
||||||
return wp.IsInRole(WindowsBuiltInRole.Administrator);
|
return wp.IsInRole(WindowsBuiltInRole.Administrator);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Trace.TraceInformation($"The current user is not an administrator, or the check failed: {ex.Message}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -226,7 +219,7 @@ namespace WelsonJS.Launcher
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Failed to run as administrator: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show($"Failed to run as Administrator: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user