Fix Server
This commit is contained in:
1 parent
75ff5a0291
commit
51a5165308
4 files changed
+151
-56
No files matched your search
@@ -30,25 +30,29 @@ namespace WebserverInitalConfig
|
||||
private static void Main(string[] args)
|
||||
// ReSharper restore InconsistentNaming
|
||||
{
|
||||
int result = 0;
|
||||
try
|
||||
{
|
||||
int port;
|
||||
if (args.Length < 2 || !int.TryParse(args[0], out port))
|
||||
if (args.Length < 3 || !int.TryParse(args[1], out port))
|
||||
{
|
||||
Console.WriteLine("Usage: VocaluxeServerConfig port isHttps");
|
||||
Environment.Exit(-1);
|
||||
Console.WriteLine("Usage: VocaluxeServerConfig exeName port isHttps [reserve]");
|
||||
result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
CConfigHttpApi config = new CConfigHttpApi("Vocaluxe", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Vocaluxe.exe"), "0.0.0.0", port, true);
|
||||
String exeName = args[0];
|
||||
bool isSecure = (args[2].ToLower() == "true");
|
||||
bool doReserve = (args.Length >= 4 && args[3].ToLower() == "true");
|
||||
CConfigHttpApi config = new CConfigHttpApi(exeName, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, exeName), "0.0.0.0", port, true);
|
||||
try
|
||||
{
|
||||
config.AddFirewallRule();
|
||||
if (args[1].ToLower() == "true")
|
||||
if (isSecure)
|
||||
config.CreateAndAddCert(Dns.GetHostName());
|
||||
|
||||
if ((args.Length >= 3 && args[2] == "reserve") || CConfigHttpApi.IsAdministrator())
|
||||
config.ReserveUrl();
|
||||
if (doReserve || CConfigHttpApi.IsAdministrator())
|
||||
config.ReserveUrl(isSecure);
|
||||
}
|
||||
catch (AuthenticationException)
|
||||
{
|
||||
@@ -56,8 +60,8 @@ namespace WebserverInitalConfig
|
||||
{
|
||||
UseShellExecute = true,
|
||||
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory,
|
||||
FileName = Process.GetCurrentProcess().MainModule.FileName,
|
||||
Arguments = args[0] + " " + args[1],
|
||||
FileName = AppDomain.CurrentDomain.FriendlyName,
|
||||
Arguments = String.Join(" ", args),
|
||||
Verb = "runas",
|
||||
CreateNoWindow = true,
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
@@ -65,21 +69,28 @@ namespace WebserverInitalConfig
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start(proc);
|
||||
using (Process p = Process.Start(proc))
|
||||
{
|
||||
p.WaitForExit();
|
||||
result = p.ExitCode;
|
||||
p.Close();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// The user refused the elevation.
|
||||
// Do nothing and return directly ...
|
||||
Environment.Exit(-1);
|
||||
result = -3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Error while installing server: " + e.Message);
|
||||
MessageBox.Show("Error while installing server: " + e.Message + "\r\n\r\nIn " + e.TargetSite + "\r\nBacktrace: " + e.StackTrace);
|
||||
result = -4;
|
||||
}
|
||||
Environment.Exit(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user