Merge branch 'main' of https://gitea.tcse.us/tricounty/tcse-deploy
This commit is contained in:
commit
96020cd301
@ -1,17 +1,18 @@
|
|||||||
# Script to set ImageGlass as default for specified file types
|
# Script to set ImageGlass as default for specified file types
|
||||||
$fileTypes = @(".png", ".jpg", ".jpeg", ".webp", ".gif", ".tiff", ".bmp", ".heif", ".heic")
|
$fileTypes = @(".png", ".jpg", ".jpeg", ".webp", ".gif", ".tiff", ".bmp", ".heif", ".heic")
|
||||||
$setUserFtaPath = "C:\Scripts\Software\setuserfta.exe"
|
$setUserFtaPath = "C:\Scripts\Software\setuserfta.exe"
|
||||||
|
$imageGlassPath = "C:\Program Files\ImageGlass\igcmd.exe"
|
||||||
|
$imageGlassRegistryPath = "HKCU:\Software\ImageGlass\Capabilities\FileAssociations"
|
||||||
|
|
||||||
# Function to check and set default app for a file type
|
# Function to check and set default app for a file type
|
||||||
function Set-DefaultAppIfNeeded {
|
function Set-DefaultAppIfNeeded {
|
||||||
param(
|
param(
|
||||||
[string]$fileType
|
[string]$fileType
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Get the current default app for the file type
|
# Get the current default app for the file type
|
||||||
$currentDefault = (Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$fileType\UserChoice" -ErrorAction SilentlyContinue).ProgId
|
$currentDefault = (Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$fileType\UserChoice" -ErrorAction SilentlyContinue).ProgId
|
||||||
|
|
||||||
# Check if ImageGlass is not the default
|
# Check if ImageGlass is not the default
|
||||||
if ($currentDefault -ne "ImageGlass") {
|
if ($currentDefault -ne "ImageGlass") {
|
||||||
Write-Host "Setting ImageGlass as default for $fileType"
|
Write-Host "Setting ImageGlass as default for $fileType"
|
||||||
@ -21,7 +22,7 @@ function Set-DefaultAppIfNeeded {
|
|||||||
Write-Error "setuserfta.exe not found at $setUserFtaPath"
|
Write-Error "setuserfta.exe not found at $setUserFtaPath"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run setuserfta.exe to set ImageGlass as default
|
# Run setuserfta.exe to set ImageGlass as default
|
||||||
Start-Process $setUserFtaPath -ArgumentList "`"$fileType`" ImageGlass" -Wait -NoNewWindow
|
Start-Process $setUserFtaPath -ArgumentList "`"$fileType`" ImageGlass" -Wait -NoNewWindow
|
||||||
}
|
}
|
||||||
@ -34,9 +35,49 @@ function Set-DefaultAppIfNeeded {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if ImageGlass command for setting defaults is needed
|
||||||
|
function Test-ImageGlassFileAssociations {
|
||||||
|
# Check if the registry path exists
|
||||||
|
if (-not (Test-Path $imageGlassRegistryPath)) {
|
||||||
|
Write-Host "ImageGlass registry path does not exist."
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check each file type
|
||||||
|
$missingAssociations = $false
|
||||||
|
foreach ($type in $fileTypes) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Try to get the property value directly
|
||||||
|
$associationValue = Get-ItemPropertyValue -Path $imageGlassRegistryPath -Name $type -ErrorAction Stop
|
||||||
|
|
||||||
|
# If we get here and the value is null or empty, consider it missing
|
||||||
|
if ([string]::IsNullOrWhiteSpace($associationValue)) {
|
||||||
|
Write-Host "Empty association for $type"
|
||||||
|
$missingAssociations = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "No association found for $type"
|
||||||
|
$missingAssociations = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $missingAssociations
|
||||||
|
}
|
||||||
|
|
||||||
# Process each file type
|
# Process each file type
|
||||||
foreach ($type in $fileTypes) {
|
foreach ($type in $fileTypes) {
|
||||||
Set-DefaultAppIfNeeded -fileType $type
|
Set-DefaultAppIfNeeded -fileType $type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if global defaults need to be set
|
||||||
|
if (Test-ImageGlassFileAssociations) {
|
||||||
|
Write-Host "Setting global defaults for ImageGlass"
|
||||||
|
Start-Process "$imageGlassPath" -ArgumentList "set-default-viewer .png;.jpg;.jpeg;.webp;.gif;.tiff;.bmp;.heif;.heic" -Wait -NoNewWindow
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "ImageGlass file associations are already completely configured."
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "File type default app check completed."
|
Write-Host "File type default app check completed."
|
||||||
7
Patches/ImageGlass/igconfig.admin.json
Normal file
7
Patches/ImageGlass/igconfig.admin.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"_Metadata": {
|
||||||
|
"Description": "ImageGlass configuration file",
|
||||||
|
"Version": "9.0"
|
||||||
|
},
|
||||||
|
"QuickSetupVersion": 9
|
||||||
|
}
|
||||||
@ -34,6 +34,7 @@ winget install --exact --id VideoLAN.VLC --silent
|
|||||||
:: Install ImageGlass Image Viewer
|
:: Install ImageGlass Image Viewer
|
||||||
echo Installing ImageGlass...
|
echo Installing ImageGlass...
|
||||||
winget install --exact --id DuongDieuPhap.ImageGlass --silent
|
winget install --exact --id DuongDieuPhap.ImageGlass --silent
|
||||||
|
powershell Copy-Item 'C:\Scripts\Patches\ImageGlass\igconfig.admin.json' 'C:\Program Files\ImageGlass'
|
||||||
|
|
||||||
:: Run Debloat Script
|
:: Run Debloat Script
|
||||||
powershell -ExecutionPolicy Bypass -File "C:\Scripts\Software\Win11Debloat\Win11Debloat.ps1" -Silent -Sysprep -RemoveApps -RemoveCommApps -RemoveW11Outlook -RemoveDevApps -RemoveGamingApps -DisableDVR -ClearStartAllUsers -DisableTelemetry -DisableBing -DisableSuggestions -DisableLockscreenTips -ShowKnownFileExt -TaskbarAlignLeft -ShowSearchIconTb -HideTaskview -HideChat -DisableWidgets -DisableCopilot -DisableRecall
|
powershell -ExecutionPolicy Bypass -File "C:\Scripts\Software\Win11Debloat\Win11Debloat.ps1" -Silent -Sysprep -RemoveApps -RemoveCommApps -RemoveW11Outlook -RemoveDevApps -RemoveGamingApps -DisableDVR -ClearStartAllUsers -DisableTelemetry -DisableBing -DisableSuggestions -DisableLockscreenTips -ShowKnownFileExt -TaskbarAlignLeft -ShowSearchIconTb -HideTaskview -HideChat -DisableWidgets -DisableCopilot -DisableRecall
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user