Merge pull request #31 from kimmknight/issue29

Added function to look for rdpsign.exe in multiple locations.
This commit is contained in:
Mr. Brian Gale 2020-08-20 08:56:50 -06:00 committed by GitHub
commit 2c89dd8b1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View File

@ -119,9 +119,14 @@ Public Class RDPSign
End If End If
'If we get here, we should be good to run the command to sign the RDP file. 'If we get here, we should be good to run the command to sign the RDP file.
Dim Command As String = GetSysDir() & "\rdpsign.exe"
'Grab the rdpsign.exe location and then verify that it exists
Dim Command = GetRdpsignExeLocation()
If My.Computer.FileSystem.FileExists(Command) Then If My.Computer.FileSystem.FileExists(Command) Then
Dim Arguments As String Dim Arguments As String
Dim FileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Command) Dim FileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Command)
' On my windows 10 computer, the argument is /sha256 instead of /sha1. /sha1 doesn't work. ' On my windows 10 computer, the argument is /sha256 instead of /sha1. /sha1 doesn't work.
@ -147,6 +152,31 @@ Public Class RDPSign
End Sub End Sub
''' <summary>
''' Find the full path to rdpsign.exe from a list of possible locations
''' </summary>
''' <returns>A path to rdpsign.exe or an empty string</returns>
Function GetRdpsignExeLocation()
'Each path to check for rdpsign.exe is added to this array.
'If it is found in more than one location, the lowest in the list will be selected.
Dim PossibleRdpsignPaths() As String = {
GetSysDir(),
My.Application.Info.DirectoryPath
}
Dim FinalRdpSignPath As String = ""
For Each RdpsignPath In PossibleRdpsignPaths
If My.Computer.FileSystem.FileExists(RdpsignPath & "\rdpsign.exe") Then
FinalRdpSignPath = RdpsignPath & "\rdpsign.exe"
End If
Next
Return FinalRdpSignPath
End Function
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Function GetSysDir() As String Function GetSysDir() As String

View File

@ -34,7 +34,7 @@ Public Class RemoteAppCreateClientConnection
MSIRadioButton.Text = "MSI installer (requires WiX Toolset)" MSIRadioButton.Text = "MSI installer (requires WiX Toolset)"
End If End If
If Not My.Computer.FileSystem.FileExists(GetSysDir() & "\rdpsign.exe") Then If Not My.Computer.FileSystem.FileExists(rdpSign.GetRdpsignExeLocation) Then
GroupBoxSignRDP.Enabled = False GroupBoxSignRDP.Enabled = False
GroupBoxSignRDP.Text += " (requires rdpsign.exe)" GroupBoxSignRDP.Text += " (requires rdpsign.exe)"
GroupBoxSignRDP.Tag = "noexe" GroupBoxSignRDP.Tag = "noexe"