fileIcon Module
Extract a file's associated icon and save it as an .ico file.
javascript
import { fileIcon } from "system";Availability
Available in the Main script only.
Table of Contents
Methods
fileIcon.extractIcon(filePath, outIcoPath [, size]) #
fileIcon
Extracts the shell icon associated with a file and writes it to an .ico file on disk. Uses Windows Shell APIs to retrieve the icon, supporting both embedded icons (like those in .exe/.dll files) and file type associations.
Icon Sources
- Executable files (.exe, .dll) may contain embedded icons
- Other files use the icon associated with their file type registration in Windows
- The function attempts to get the best quality icon available at the requested size
File Paths
Both filePath and outIcoPath should be absolute paths or relative to the current working directory. The output directory must exist before calling this function.
PARAMETERS
filePath string
Source file path (.exe, .dll, or any file with an associated icon).
outIcoPath string
Output path for the extracted .ico file.
size number OPTIONAL
Preferred icon size in pixels. Defaults to 48.
RETURNS:
boolean true if the icon was extracted and written successfully, false otherwise.javascript
import { fileIcon } from "system";
const ok = fileIcon.extractIcon(
"C:\\Windows\\System32\\notepad.exe",
__dirname + "\\notepad.ico",
48
);
console.log("Extracted:", ok);fileIcon.extractFileIcon(filePath, outIcoPath [, size]) #
fileIcon
Alias of fileIcon.extractIcon(). Identical behavior.
PARAMETERS
filePath string
Source file path.
outIcoPath string
Output path for the extracted .ico file.
size number OPTIONAL
Preferred icon size in pixels. Defaults to 48.
RETURNS:
boolean true if the icon was extracted and written successfully, false otherwise.javascript
import { fileIcon } from "system";
fileIcon.extractFileIcon("C:\\Windows\\System32\\calc.exe", __dirname + "\\calc.ico");