-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-FullFilenameOfSignToolExe.ps1
59 lines (48 loc) · 1.95 KB
/
Get-FullFilenameOfSignToolExe.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<#
.SYNOPSIS
Find SignTool.exe in a list of known-locations or in the current folder as fullpath
.DESCRIPTION
Find SignTool.exe in a list of known-locations or in the current folder as fullpath
.INPUTS
CheckCurrentDirectory = Should the current directory included in the search
.OUTPUTS
Fullpath of SignTool.exe
.EXAMPLE
$exeFile = Get-FullFilenameOfAppCertExe
.EXAMPLE
$exeFile = Get-FullFilenameOfAppCertExe -CheckCurrentDirectory $true
#>
function Get-FullFilenameOfSignToolExe()
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[bool] $CheckCurrentDirectory = $false
)
$arrProgramFilesFolders = ( ${env:ProgramFiles}, ${env:ProgramFiles(x86)} )
$arrSignTool = @();
if($CheckCurrentDirectory) {
$arrSignTool += "signtool.exe"
}
foreach ($folder in $arrProgramFilesFolders) {
$arrSignTool += "$folder\Windows Kits\10\bin\x64\signtool.exe"
$arrSignTool += "$folder\Windows Kits\10\bin\x86\signtool.exe"
$arrSignTool += "$folder\Windows Kits\8.1\bin\x64\signtool.exe"
$arrSignTool += "$folder\Windows Kits\8.1\bin\x86\signtool.exe"
$arrSignTool += "$folder\Windows Kits\8.0\bin\x64\signtool.exe"
$arrSignTool += "$folder\Windows Kits\8.0\bin\x86\signtool.exe"
}
foreach ($exeFile in $arrSignTool)
{
if (Test-Path $exeFile)
{
Write-Host ("##vso[task.setvariable variable=FullFilenameOfSignToolExe;]$exeFile")
Write-Host "SignTool.exe was found here: [ $exeFile ] and set as env variable 'FullFilenameOfSignToolExe'" -ForegroundColor Green
return $exeFile
}
}
Write-Host "SignTool.exe not found. Check Windows 10 SDK needed - https://go.microsoft.com/fwlink/p/?LinkID=822845 to get a SDK" -ForegroundColor Red
throw [System.IO.FileNotFoundException] "SignTool.exe not found!"
return ""
}
# Get-FullFilenameOfSignToolExe -CheckCurrentDirectory $true