diff --git a/AdvancedConnectPlugin/CHANGELOG.txt b/AdvancedConnectPlugin/CHANGELOG.txt index 9a398fd..9d972d9 100644 --- a/AdvancedConnectPlugin/CHANGELOG.txt +++ b/AdvancedConnectPlugin/CHANGELOG.txt @@ -1,4 +1,5 @@ +1.0.1 +Added environment variables resolving - -0.1.0 +1.0.0 First version. No release history before this. \ No newline at end of file diff --git a/AdvancedConnectPlugin/Data/ConnectionItem.cs b/AdvancedConnectPlugin/Data/ConnectionItem.cs index ed7f771..f21f504 100644 --- a/AdvancedConnectPlugin/Data/ConnectionItem.cs +++ b/AdvancedConnectPlugin/Data/ConnectionItem.cs @@ -27,16 +27,23 @@ public class ConnectionItem /** - * Replaces all placeholders with keepass compiling engine + * Replaces all placeholders with keepass compiling engine and replace os environment variables */ protected String fillPlaceholders(String applicationOptions) { + String resolvedPathOrOptions = String.Empty; + + //Resolv keepass variables Boolean encodeAsAutoType = false; Boolean encodeQuotesForCommandline = true; SprCompileFlags compileFlags = SprCompileFlags.All; // Which placeholders should be replaced SprContext replaceContext = new SprContext(this.keepassEntry, this.keepassDatabase, compileFlags, encodeAsAutoType, encodeQuotesForCommandline); + resolvedPathOrOptions = SprEngine.Compile(applicationOptions, replaceContext); + + //Resolv OS variables + resolvedPathOrOptions = Environment.ExpandEnvironmentVariables(resolvedPathOrOptions); - return SprEngine.Compile(applicationOptions, replaceContext); + return resolvedPathOrOptions; } } diff --git a/AdvancedConnectPlugin/Data/CustomConnectionItem.cs b/AdvancedConnectPlugin/Data/CustomConnectionItem.cs index d73e585..2e3e962 100644 --- a/AdvancedConnectPlugin/Data/CustomConnectionItem.cs +++ b/AdvancedConnectPlugin/Data/CustomConnectionItem.cs @@ -34,8 +34,8 @@ public Boolean startConnection(out String errorMessage) { errorMessage = String.Empty; - //Check if application path exist - if (File.Exists(this.application.path)) + //Check if application path exist with resolved OS variables + if (File.Exists(Environment.ExpandEnvironmentVariables(this.application.path))) { //Overwrite application options if set in keepass entry if (this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField).Length > 0) @@ -49,7 +49,7 @@ public Boolean startConnection(out String errorMessage) Thread.CurrentThread.IsBackground = true; //Background threads will stop automatically on program close //Fill placeholders in options and start programm - StartProcess.Start(this.application.path, fillPlaceholders(this.application.options)); + StartProcess.Start(fillPlaceholders(this.application.path), fillPlaceholders(this.application.options)); }).Start(); diff --git a/AdvancedConnectPlugin/Data/RDPConnectionItem.cs b/AdvancedConnectPlugin/Data/RDPConnectionItem.cs index 0cfc3ba..2bc7440 100644 --- a/AdvancedConnectPlugin/Data/RDPConnectionItem.cs +++ b/AdvancedConnectPlugin/Data/RDPConnectionItem.cs @@ -46,9 +46,9 @@ public Boolean startConnection(out String errorMessage) errorMessage = String.Empty; //Check if application path exist - if (File.Exists(RDPConnectionItem.pathToRemoteDesktop)) + if (File.Exists(Environment.ExpandEnvironmentVariables(RDPConnectionItem.pathToRemoteDesktop))) { - if (File.Exists(RDPConnectionItem.pathToCMDKey)) + if (File.Exists(Environment.ExpandEnvironmentVariables(RDPConnectionItem.pathToCMDKey))) { //Overwrite the default rdp parameter if set in keepass entry if (this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField).Length > 0) diff --git a/AdvancedConnectPlugin/GUI/ContextMenuExtension.cs b/AdvancedConnectPlugin/GUI/ContextMenuExtension.cs index f9958eb..dd8ba80 100644 --- a/AdvancedConnectPlugin/GUI/ContextMenuExtension.cs +++ b/AdvancedConnectPlugin/GUI/ContextMenuExtension.cs @@ -80,7 +80,7 @@ private void entryContextMenu_Opened(object sender, EventArgs e) { menuItem = new ToolStripMenuItem(); menuItem.Text = application.name; - try { menuItem.Image = System.Drawing.Icon.ExtractAssociatedIcon(application.path).ToBitmap(); } catch (Exception) { } //Extracts the icon from the executable and sets it as context menut item bitmap + try { menuItem.Image = System.Drawing.Icon.ExtractAssociatedIcon(Environment.ExpandEnvironmentVariables(application.path)).ToBitmap(); } catch (Exception) { } //Resolvs OS variables and extracts the icon from the executable and sets it as context menut item bitmap menuItem.Tag = new Data.CustomConnectionItem(this.plugin, application, selectedEntries[0]); //Contains the spezific connectionitem (kpentry + applicationitem) object reference menuItem.Click += entryContextMenuItem_CustomApplication_Click; menuItemList.Add(menuItem); diff --git a/AdvancedConnectPlugin/Properties/AssemblyInfo.cs b/AdvancedConnectPlugin/Properties/AssemblyInfo.cs index 07d2678..22c1854 100644 --- a/AdvancedConnectPlugin/Properties/AssemblyInfo.cs +++ b/AdvancedConnectPlugin/Properties/AssemblyInfo.cs @@ -1,4 +1,16 @@ -using System.Reflection; +/* +Copyright 2016 TGW Software Services GmbH + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is +distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. +*/ +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,5 +44,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.1.0")] +[assembly: AssemblyFileVersion("1.0.1.0")]