Skip to content

Commit

Permalink
fix: env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyueta authored Sep 18, 2023
1 parent 1974ded commit e8999d0
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ title: Disable Network Navigation Pane in Explorer
description: Disables the network navigation pane/item in the Explorer sidebar for QoL by default, as it is mostly unused
privilege: TrustedInstaller
actions:
- !registryKey: {path: 'HKCU\Software\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}', operation: add}
- !registryKey: {path: 'HKCU\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}', operation: add}
- !registryValue:
path: 'HKCU\Software\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}'
path: 'HKCU\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}'
value: 'System.IsPinnedToNameSpaceTree'
data: '0'
type: REG_DWORD
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function DeleteEdgeUpdate {
sc.exe delete edgeupdatem | Out-Null

# delete the Edge Update folder
Remove-Item -Path "C:\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force | Out-Null
Remove-Item -Path "$env:SystemDrive\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force | Out-Null

# revert error action preference
$global:ErrorActionPreference = 'Continue'
Expand Down
274 changes: 137 additions & 137 deletions src/playbook/Executables/AtlasModules/Scripts/online-sxs.cmd
Original file line number Diff line number Diff line change
@@ -1,138 +1,138 @@
<# : batch portion
@echo off
:: GPL-3.0-only license
:: he3als 2023
:: https://github.com/he3als/online-sxs

if "%~1"=="-Help" (goto help) else (if "%~1"=="-help" (goto help) else (if "%~1"=="/h" (goto help) else (goto main)))

:help
echo Usage = online-sxs.cmd [-Help] [[-Silent] -CabPath ""]
exit /b

:main
fltmc >nul 2>&1 || (
echo Administrator privileges are required.
if "%*"=="" (
PowerShell Start -Verb RunAs '%0' 2> nul || goto error
) else (
PowerShell Start -Verb RunAs '%0' -ArgumentList '%*' 2> nul || goto error
)
exit /b 0
)

set args= & set "args1=%*"
if defined args1 set "args=%args1:"='%"
powershell -nop "& ([Scriptblock]::Create((Get-Content '%~f0' -Raw))) %args%"
exit /b %errorlevel%

:error
echo You must run this script as admin.
pause & exit /b 1

: end batch / begin PowerShell #>

param (
[string]$CabPaths,
[switch]$Silent
)

# You can automate this script with variables as well:
# $CabPaths = "C:\Package.cab"
# Note: only works if $cabPath is defined
# $Silent = $true

if ($CabPaths) {
$cabArg = $true

if (!(Test-Path $CabPaths -PathType Leaf)) {
Write-Host "The specified files do not exist or aren't files." -ForegroundColor Red
exit 1
}

if (!((Get-Item $CabPaths).Extension -eq '.cab')) {
Write-Host "The specified files are not .cab files." -ForegroundColor Red
exit 1
}
} else {$Silent = $false}

$certRegPath = "HKLM:\SOFTWARE\Microsoft\SystemCertificates\ROOT\Certificates"

function PauseNul ($message = "Press any key to exit... ") {
Write-Host $message -NoNewLine
$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') | Out-Null
}

if ($silent) {$ProgressPreference = 'SilentlyContinue'}

if (!($cabArg)) {
Write-Host "This will install a specified CBS package online, meaning live on your current install of Windows." -ForegroundColor Yellow
Start-Sleep 1
PauseNul "Press any key to continue... "
Write-Host "`n"

Write-Warning "Opening file dialog to select CBS package CAB..."
Add-Type -AssemblyName System.Windows.Forms
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$openFileDialog.Multiselect = $true
$openFileDialog.Filter = "CBS Package Files (*.cab)|*.cab"
$openFileDialog.Title = "Select a CBS Package File"
if ($openFileDialog.ShowDialog() -eq 'OK') {
Clear-Host
} else {exit}
}

function ProcessCab($cabPath) {
try {
if (!($Silent)) {
$filePath = Split-Path $cabPath -Leaf
if ($global:notFirstCab) {Write-Host ""}
Write-Host "Installing $filePath..." -ForegroundColor Green
Write-Host "----------------------------------------------------------------------------------------" -ForegroundColor Blue
$global:notFirstCab = $true
}

if (!($silent)) {Write-Warning "Importing and checking certificate..."}
try {
$cert = (Get-AuthenticodeSignature $cabPath).SignerCertificate
foreach ($usage in $cert.Extensions.EnhancedKeyUsages) { if ($usage.Value -eq "1.3.6.1.4.1.311.10.3.6") { $correctUsage = $true } }
if (!($correctUsage)) {
Write-Host 'The certificate inside of the CAB selected does not have the "Windows System Component Verification" enhanced key usage.' -ForegroundColor Red
if (!($cabArg)) {PauseNul}; exit 1
}
$certPath = [System.IO.Path]::GetTempFileName()
[System.IO.File]::WriteAllBytes($certPath, $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert))
Import-Certificate $certPath -CertStoreLocation "Cert:\LocalMachine\Root" | Out-Null
Copy-Item -Path "$certRegPath\$($cert.Thumbprint)" "$certRegPath\8A334AA8052DD244A647306A76B8178FA215F344" -Force | Out-Null
} catch {
Write-Host "`nSomething went wrong importing and checking the certificate of: $cabPath" -ForegroundColor Red
Write-Host "$_`n" -ForegroundColor Red
if (!($cabArg)) {PauseNul}; exit 1
}

if (!($silent)) {Write-Warning "Adding package..."}
try {
Add-WindowsPackage -Online -PackagePath $cabPath -NoRestart -IgnoreCheck -LogLevel 1 *>$null
} catch {
Write-Host "Something went wrong adding the package: $cabPath" -ForegroundColor Red
Write-Host "$_`n" -ForegroundColor Red
if (!($cabArg)) {PauseNul}; exit 1
}
} finally {
if (!($silent)) {Write-Warning "Cleaning up certificates..."}
Get-ChildItem "Cert:\LocalMachine\Root\$($cert.Thumbprint)" | Remove-Item -Force | Out-Null
Remove-Item "$certRegPath\8A334AA8052DD244A647306A76B8178FA215F344" -Force -Recurse | Out-Null
}
}

if ($cabArg) {
foreach ($cabPath in $CabPaths) {ProcessCab $cabPath}
} else {
foreach ($cabPath in $openFileDialog.FileNames) {ProcessCab $cabPath}
}

if (!($silent)) {Write-Host "`nCompleted!" -ForegroundColor Green}
if (!($cabArg)) {
choice /c yn /n /m "Would you like to restart now to apply the changes? [Y/N] "
if ($lastexitcode -eq 1) {Restart-Computer}
<# : batch portion
@echo off
:: GPL-3.0-only license
:: he3als 2023
:: https://github.com/he3als/online-sxs

if "%~1"=="-Help" (goto help) else (if "%~1"=="-help" (goto help) else (if "%~1"=="/h" (goto help) else (goto main)))

:help
echo Usage = online-sxs.cmd [-Help] [[-Silent] -CabPath ""]
exit /b

:main
fltmc >nul 2>&1 || (
echo Administrator privileges are required.
if "%*"=="" (
PowerShell Start -Verb RunAs '%0' 2> nul || goto error
) else (
PowerShell Start -Verb RunAs '%0' -ArgumentList '%*' 2> nul || goto error
)
exit /b 0
)

set args= & set "args1=%*"
if defined args1 set "args=%args1:"='%"
powershell -nop "& ([Scriptblock]::Create((Get-Content '%~f0' -Raw))) %args%"
exit /b %errorlevel%

:error
echo You must run this script as admin.
pause & exit /b 1

: end batch / begin PowerShell #>

param (
[string]$CabPaths,
[switch]$Silent
)

# You can automate this script with variables as well:
# $CabPaths = "$env:SystemDrive\Package.cab"
# Note: only works if $cabPath is defined
# $Silent = $true

if ($CabPaths) {
$cabArg = $true

if (!(Test-Path $CabPaths -PathType Leaf)) {
Write-Host "The specified files do not exist or aren't files." -ForegroundColor Red
exit 1
}

if (!((Get-Item $CabPaths).Extension -eq '.cab')) {
Write-Host "The specified files are not .cab files." -ForegroundColor Red
exit 1
}
} else {$Silent = $false}

$certRegPath = "HKLM:\SOFTWARE\Microsoft\SystemCertificates\ROOT\Certificates"

function PauseNul ($message = "Press any key to exit... ") {
Write-Host $message -NoNewLine
$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') | Out-Null
}

if ($silent) {$ProgressPreference = 'SilentlyContinue'}

if (!($cabArg)) {
Write-Host "This will install a specified CBS package online, meaning live on your current install of Windows." -ForegroundColor Yellow
Start-Sleep 1
PauseNul "Press any key to continue... "
Write-Host "`n"

Write-Warning "Opening file dialog to select CBS package CAB..."
Add-Type -AssemblyName System.Windows.Forms
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$openFileDialog.Multiselect = $true
$openFileDialog.Filter = "CBS Package Files (*.cab)|*.cab"
$openFileDialog.Title = "Select a CBS Package File"
if ($openFileDialog.ShowDialog() -eq 'OK') {
Clear-Host
} else {exit}
}

function ProcessCab($cabPath) {
try {
if (!($Silent)) {
$filePath = Split-Path $cabPath -Leaf
if ($global:notFirstCab) {Write-Host ""}
Write-Host "Installing $filePath..." -ForegroundColor Green
Write-Host "----------------------------------------------------------------------------------------" -ForegroundColor Blue
$global:notFirstCab = $true
}

if (!($silent)) {Write-Warning "Importing and checking certificate..."}
try {
$cert = (Get-AuthenticodeSignature $cabPath).SignerCertificate
foreach ($usage in $cert.Extensions.EnhancedKeyUsages) { if ($usage.Value -eq "1.3.6.1.4.1.311.10.3.6") { $correctUsage = $true } }
if (!($correctUsage)) {
Write-Host 'The certificate inside of the CAB selected does not have the "Windows System Component Verification" enhanced key usage.' -ForegroundColor Red
if (!($cabArg)) {PauseNul}; exit 1
}
$certPath = [System.IO.Path]::GetTempFileName()
[System.IO.File]::WriteAllBytes($certPath, $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert))
Import-Certificate $certPath -CertStoreLocation "Cert:\LocalMachine\Root" | Out-Null
Copy-Item -Path "$certRegPath\$($cert.Thumbprint)" "$certRegPath\8A334AA8052DD244A647306A76B8178FA215F344" -Force | Out-Null
} catch {
Write-Host "`nSomething went wrong importing and checking the certificate of: $cabPath" -ForegroundColor Red
Write-Host "$_`n" -ForegroundColor Red
if (!($cabArg)) {PauseNul}; exit 1
}

if (!($silent)) {Write-Warning "Adding package..."}
try {
Add-WindowsPackage -Online -PackagePath $cabPath -NoRestart -IgnoreCheck -LogLevel 1 *>$null
} catch {
Write-Host "Something went wrong adding the package: $cabPath" -ForegroundColor Red
Write-Host "$_`n" -ForegroundColor Red
if (!($cabArg)) {PauseNul}; exit 1
}
} finally {
if (!($silent)) {Write-Warning "Cleaning up certificates..."}
Get-ChildItem "Cert:\LocalMachine\Root\$($cert.Thumbprint)" | Remove-Item -Force | Out-Null
Remove-Item "$certRegPath\8A334AA8052DD244A647306A76B8178FA215F344" -Force -Recurse | Out-Null
}
}

if ($cabArg) {
foreach ($cabPath in $CabPaths) {ProcessCab $cabPath}
} else {
foreach ($cabPath in $openFileDialog.FileNames) {ProcessCab $cabPath}
}

if (!($silent)) {Write-Host "`nCompleted!" -ForegroundColor Green}
if (!($cabArg)) {
choice /c yn /n /m "Would you like to restart now to apply the changes? [Y/N] "
if ($lastexitcode -eq 1) {Restart-Computer}
}
2 changes: 1 addition & 1 deletion src/playbook/Executables/KILLKPH.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Remove-Item -Path $settingsDirectory -Recurse -Force -EA SilentlyContinue
New-Item -Path $settingsDirectory -ItemType Directory -Force | Out-Null
$settingsXml | Set-Content -Path $settingsFilePath -Force

$userDirectories = Get-ChildItem -Path "C:\Users" -Directory -Exclude "Public", "Default", "Default User", "All Users"
$userDirectories = Get-ChildItem -Path "$env:SystemDrive\Users" -Directory -Exclude "Public", "Default", "Default User", "All Users"
foreach ($userDir in $userDirectories) {
$destinationPath = Join-Path $userDir.FullName "AppData\Roaming\Process Hacker 2\settings.xml"
$destinationDirectory = Split-Path -Path $destinationPath -Parent
Expand Down
Loading

0 comments on commit e8999d0

Please sign in to comment.