This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import struct | |
| import ctypes | |
| import re | |
| user32 = ctypes.WinDLL(r'C:\Windows\System32\user32.dll') | |
| icofile = r'<filepath_to_your_icofile>' # set your file name!!! | |
| print(icofile) | |
| with open(icofile, 'rb') as f: | |
| data = f.read() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| ICO file reader. | |
| .DESCRIPTION | |
| An AIO function to read and export icons stored within .ICO files. Read-Ico can export high-quality icons of all sizes, and all color formats to a number of formats, including ico, png, jpg, and gif. | |
| Key features: | |
| - Multisize high-quality ICO | |
| - Ability to create a separate ICO for each size at once | |
| - ICO integrity check | |
| - Ability interactively select image file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Convert-IcoToPng ([string]$icofile) { | |
| # Runtime validation | |
| if ($PSVersionTable.PSEdition -eq 'Core') {return} | |
| if (-not $icofile -or -not (Test-Path $icofile)) {return} | |
| # ICO validation | |
| $signature = Get-Content -Path $icofile -Encoding Byte -TotalCount 6 -ErrorAction 0 | |
| if (([System.BitConverter]::ToInt32(($signature[0..3]),0)) -ne 0x10000) {return} | |
| if (([System.BitConverter]::ToInt16(($signature[4,5]),0)) -gt 1) {return} # single-size | |
| Add-Type -AssemblyName System.Runtime.WindowsRuntime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function New-PercentBar { | |
| [cmdletbinding()] | |
| param ( | |
| [parameter(ValueFromPipeline)] | |
| [alias('inputobject')][decimal[]] $value, | |
| [alias('range')][decimal] $scale, | |
| [int] $barlength, | |
| [consolecolor] $color, | |
| [switch] $hint | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Show-Progress { | |
| param ( | |
| [scriptblock] $scriptblock, | |
| [int] $width, | |
| [consolecolor] $color, | |
| [string] $type, # growth | fill | bounce | tide | |
| [switch] $passthru | |
| ) | |
| if (-not $scriptblock) {return} | |
| if ($width -lt 1) {$width = 10} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function prompt { | |
| function Get-LastCmdTime { | |
| $diffPromptTime = $null | |
| $lastCmd = Get-History -Count 1 | |
| if ($lastCmd -ne $null) { | |
| $diff = $lastCmd.EndExecutionTime - $lastCmd.StartExecutionTime | |
| $msfractional = $diff.TotalMilliseconds - [Math]::Truncate($diff.TotalMilliseconds) | |
| $ms = $msfractional + $diff.Milliseconds | |
| if ($diff.Hours) {'{0}h:{1}m:{2}s:{3:N2}ms' -f $diff.Hours,$diff.Minutes,$diff.Seconds,$ms} | |
| elseif ($diff.Minutes) {'{0}m:{1}s:{2:N2}ms' -f $diff.Minutes,$diff.Seconds,$ms} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Windows Powershell doesn't have [System.Drawing.Icon]::ExtractIcon method | |
| # Neither ExtractIcon* functions from user32.dll have a parameter associated with size | |
| Add-Type -AssemblyName System.Drawing | |
| $Path = 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' | |
| function import-icon ([string]$file, [int]$index=0, [int[]]$sizes) { | |
| #if ([version]'7.6' -gt $PSVersionTable.PSVersion) {return} | |
| if (-not $file) {return} # -or -not (Test-Path $file -ErrorAction 0) | |
| if ($sizes.count) { # normalize sizes | |
| $sizes = @($sizes | Where-Object {$_ -gt 7 -and $_ -lt 257} | Sort-Object -Unique) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Synopsis : A utility class that extracts the list of all icons handles (all sizes, all color counts) for a binary file like DLL, EXE, or ICO | |
| Version : 3.1 | |
| Lastupdate : 2026-Aug-11 | |
| // get amount of icons stored in a dll | |
| var icons = IconReader.GetTotal(@"c:\windows\system32\imageres.dll"); | |
| // get all icons handles with index 0 from a dll | |
| var icons = IconReader.ImportIcons(@"c:\windows\system32\shell32.dll", 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| SVG to Windows ICO converter. | |
| .DESCRIPTION | |
| The script uses Inkscape app to convert SVG to PNG and then ensembles PNGs to a single ICO using .NET. | |
| Key features: | |
| - Multisize ICO | |
| - Just one Inkscape instance per multiple size conversions, i.e. a conversion time is independent on amount of sizes | |
| - Control over SVG exported area | |
| - Ability to replace colors in SVG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| An AIO function to export icons stored within .DLL and .EXE files. | |
| .DESCRIPTION | |
| Export-Icon can export icons of all sizes, and all color formats to a number of formats, including bmp, png, jpg, gif, emf, exif, icon, tiff, heif, and webp. In addition, it can also export to a different size. All sizes are native, no scaling, except custom sizes. | |
| This function quickly exports *all* icons stored within the resource file. | |
| Export-Icon is independent on .NET version. It uses a custom icon extractor engine because Windows PowerShell doesn't have [System.Drawing.Icon]::ExtractIcon method (https://learn.microsoft.com/en-us/dotnet/api/system.drawing.icon?view=netframework-4.8.1). In addition, PowerShell 7.6+ [System.Drawing.Icon]::ExtractIcon method has a limited capability. Besides, neither ExtractIcon* functions from user32.dll have a parameter associated with size. | |
| .PARAMETER Path | |
| Mandatory. Position is 0. Specifies a filepath to the resource. | |
| .PARAMETER Output |
NewerOlder