mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Merge pull request #720 from pedro2555/676
First startup ignores cons param
This commit is contained in:
@@ -218,6 +218,33 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a path to a file connections XML file for a given absolute or relative path
|
||||
/// </summary>
|
||||
/// <param name="ConsParam">The absolute or relative path to the connection XML file</param>
|
||||
/// <returns>string or null</returns>
|
||||
private static string GetCustomConsPath(string ConsParam)
|
||||
{
|
||||
// early exit condition
|
||||
if (string.IsNullOrEmpty(ConsParam))
|
||||
return null;
|
||||
|
||||
// trim invalid characters for the Combine method (see: https://msdn.microsoft.com/en-us/library/fyy7a5kt.aspx#Anchor_2)
|
||||
ConsParam = ConsParam.Trim().TrimStart('\\').Trim();
|
||||
|
||||
// fallback paths
|
||||
if (File.Exists(ConsParam))
|
||||
return ConsParam;
|
||||
|
||||
if (File.Exists(Path.Combine(GeneralAppInfo.HomePath, ConsParam)))
|
||||
return GeneralAppInfo.HomePath + Path.DirectorySeparatorChar + ConsParam;
|
||||
|
||||
if (File.Exists(Path.Combine(ConnectionsFileInfo.DefaultConnectionsPath, ConsParam)))
|
||||
return ConnectionsFileInfo.DefaultConnectionsPath + Path.DirectorySeparatorChar + ConsParam;
|
||||
|
||||
// default case
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void ParseCommandLineArgs()
|
||||
{
|
||||
@@ -282,30 +309,10 @@ namespace mRemoteNG.App
|
||||
NoReconnectParam = "norc";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(ConsParam))
|
||||
{
|
||||
if (File.Exists(cmd[ConsParam]) == false)
|
||||
{
|
||||
if (File.Exists(GeneralAppInfo.HomePath + "\\" + cmd[ConsParam]))
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = true;
|
||||
Settings.Default.CustomConsPath = GeneralAppInfo.HomePath + "\\" + cmd[ConsParam];
|
||||
return;
|
||||
}
|
||||
if (File.Exists(ConnectionsFileInfo.DefaultConnectionsPath + "\\" + cmd[ConsParam]))
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = true;
|
||||
Settings.Default.CustomConsPath = ConnectionsFileInfo.DefaultConnectionsPath + "\\" + cmd[ConsParam];
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = true;
|
||||
Settings.Default.CustomConsPath = cmd[ConsParam];
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Handle custom connection file location
|
||||
Settings.Default.CustomConsPath = GetCustomConsPath(ConsParam);
|
||||
if (Settings.Default.CustomConsPath != null)
|
||||
Settings.Default.LoadConsFromCustomLocation = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(ResetPosParam))
|
||||
{
|
||||
@@ -329,6 +336,8 @@ namespace mRemoteNG.App
|
||||
{
|
||||
Settings.Default.ResetToolbars = true;
|
||||
}
|
||||
|
||||
Settings.Default.Save();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user