Skip to content

Einck0/IconFix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IconFix 2.1

IconFix 用于修复 Windows 上 Steam 游戏快捷方式图标丢失、变白或失效的问题。程序会扫描 .url 快捷方式,提取其中的 Steam App ID 与图标文件路径,然后重新下载官方图标并写回本地。

2.0 版本改进

  • 将单文件脚本重构为清晰的包结构,方便维护和扩展。
  • 增加更稳健的管理员提权流程: 非管理员启动时会主动申请管理员权限,用户允许后会自动以提权态继续执行。
  • 补充命令行参数、版本号与项目元信息。
  • 增加基础测试,便于后续继续迭代。
  • 补充更完整的使用说明与优化学习笔记。

2.1 版本改进

  • 新增纯 PowerShell 版 IconFix.ps1,不需要安装 Python。
  • 支持在没有任何开发环境的 Windows 电脑上通过联网命令一键运行。
  • GitHub Release 包会同时附带 IconFix.exeIconFix.ps1

工作原理

  1. 扫描指定目录和公共桌面中的 .url 快捷方式。
  2. 解析快捷方式中的 URL=steam://rungameid/...IconFile=...
  3. 从 Steam 静态资源地址重新下载 .ico 图标。
  4. 将图标写回原快捷方式引用的本地图标文件。

环境要求

  • Windows
  • Python 3.10+
  • v2.0 无第三方运行时依赖

如果使用 IconFix.ps1,只需要 Windows 自带的 PowerShell 5.1 或更高版本,不需要 Python。

安装方式

pip install -r requirements.txt

requirements.txt 在 2.0 中仅作为占位说明文件保留;如果你更习惯标准安装方式,也可以直接使用:

pip install .

使用方式

推荐的一键运行方式,不需要安装 Python:

irm 'https://raw.githubusercontent.com/Einck0/IconFix/main/IconFix.ps1' | iex

如果需要直接修复扫描到的全部快捷方式,推荐使用稳定传参方式:

powershell -NoProfile -ExecutionPolicy Bypass -Command "$u='https://raw.githubusercontent.com/Einck0/IconFix/main/IconFix.ps1'; $p=Join-Path $env:TEMP 'IconFix.ps1'; Invoke-WebRequest -UseBasicParsing $u -OutFile $p; & $p -All"

如果需要指定扫描目录:

powershell -NoProfile -ExecutionPolicy Bypass -Command "$u='https://raw.githubusercontent.com/Einck0/IconFix/main/IconFix.ps1'; $p=Join-Path $env:TEMP 'IconFix.ps1'; Invoke-WebRequest -UseBasicParsing $u -OutFile $p; & $p -Path 'D:\Games\Shortcuts' -All"

也可以在项目目录直接运行 Python 版本:

python IconFix.py

常用参数:

  • -path / --path 指定扫描目录,默认是当前目录。
  • --all 直接处理扫描到的全部快捷方式,不再交互选择。
  • --no-elevate 跳过自动申请管理员权限。
  • --no-pause 结束后不等待按键,适合脚本化调用。
  • -V / --version 查看当前版本号。

示例:

python IconFix.py --path "D:\Games\Shortcuts" --all

PowerShell 版指定目录示例:

.\IconFix.ps1 -Path "D:\Games\Shortcuts" -All

管理员权限说明

2.0 版本默认会在非管理员状态下主动申请管理员权限。这是因为以下场景常常需要更高权限:

  • 修改公共桌面中的快捷方式图标
  • 写入受保护目录中的图标文件
  • 避免处理中途因为权限不足而失败

如果用户在系统弹窗中点击“允许”,程序会自动以管理员身份重新启动并继续执行;如果点击“取消”,程序会给出明确提示并停止继续操作。

项目结构

IconFix.py
IconFix.ps1
iconfix/
  __init__.py
  cli.py
  constants.py
  elevation.py
  logging_utils.py
  models.py
  scanner.py
  shortcut.py
  steam.py
  workflow.py
tests/
docs/

测试

python -m unittest discover -s tests -v

学习资料

2.0 版本的重构说明和优化思路已经整理到:

About

Fix the invalid icon of the Steam game caused by reinstalling the system or other reasons and turning it into a white icon.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors