Ensure Bin Path is Valid

This commit is contained in:
zoicware
2025-06-12 12:54:45 -04:00
committed by GitHub
parent fd706208a3
commit 345dc01743

View File

@@ -14,6 +14,11 @@ function Run-Trusted([String]$command) {
#get bin path to revert later #get bin path to revert later
$service = Get-WmiObject -Class Win32_Service -Filter "Name='TrustedInstaller'" $service = Get-WmiObject -Class Win32_Service -Filter "Name='TrustedInstaller'"
$DefaultBinPath = $service.PathName $DefaultBinPath = $service.PathName
#make sure path is valid and the correct location
$trustedInstallerPath = "$env:SystemRoot\servicing\TrustedInstaller.exe"
if($DefaultBinPath -ne $trustedInstallerPath){
$DefaultBinPath = $trustedInstallerPath
}
#convert command to base64 to avoid errors with spaces #convert command to base64 to avoid errors with spaces
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command) $bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$base64Command = [Convert]::ToBase64String($bytes) $base64Command = [Convert]::ToBase64String($bytes)