Skip to content

Commit 627dc5e

Browse files
committed
Added function to look for rdpsign.exe in multiple locations.
1 parent 121c436 commit 627dc5e

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

RDPSign/RDPSign.vb

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,14 @@ Public Class RDPSign
119119

120120
End If
121121

122-
'If we get here, we should be good to run the command to sign the RDP file.
123-
Dim Command As String = GetSysDir() & "\rdpsign.exe"
122+
'If we get here, we should be good to run the command to sign the RDP file.
123+
124+
'Grab the rdpsign.exe location and then verify that it exists
125+
126+
Dim Command = GetRdpsignExeLocation()
127+
124128
If My.Computer.FileSystem.FileExists(Command) Then
129+
125130
Dim Arguments As String
126131
Dim FileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Command)
127132
' On my windows 10 computer, the argument is /sha256 instead of /sha1. /sha1 doesn't work.
@@ -147,6 +152,31 @@ Public Class RDPSign
147152

148153
End Sub
149154

155+
''' <summary>
156+
''' Find the full path to rdpsign.exe from a list of possible locations
157+
''' </summary>
158+
''' <returns>A path to rdpsign.exe or an empty string</returns>
159+
Function GetRdpsignExeLocation()
160+
'Each path to check for rdpsign.exe is added to this array.
161+
'If it is found in more than one location, the lowest in the list will be selected.
162+
Dim PossibleRdpsignPaths() As String = {
163+
GetSysDir(),
164+
My.Application.Info.DirectoryPath
165+
}
166+
167+
Dim FinalRdpSignPath As String = ""
168+
169+
For Each RdpsignPath In PossibleRdpsignPaths
170+
If My.Computer.FileSystem.FileExists(RdpsignPath & "\rdpsign.exe") Then
171+
FinalRdpSignPath = RdpsignPath & "\rdpsign.exe"
172+
End If
173+
Next
174+
175+
Return FinalRdpSignPath
176+
177+
End Function
178+
179+
150180
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
151181

152182
Function GetSysDir() As String

remoteapp-tool/RemoteAppCreateClientConnection.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Public Class RemoteAppCreateClientConnection
3434
MSIRadioButton.Text = "MSI installer (requires WiX Toolset)"
3535
End If
3636

37-
If Not My.Computer.FileSystem.FileExists(GetSysDir() & "\rdpsign.exe") Then
37+
If Not My.Computer.FileSystem.FileExists(rdpSign.GetRdpsignExeLocation) Then
3838
GroupBoxSignRDP.Enabled = False
3939
GroupBoxSignRDP.Text += " (requires rdpsign.exe)"
4040
GroupBoxSignRDP.Tag = "noexe"

0 commit comments

Comments
 (0)