ImageGlass icon indicating copy to clipboard operation
ImageGlass copied to clipboard

ImageGlass 9.3.2.250 writes its settings inconsistently

Open skycommand opened this issue 7 months ago • 0 comments

Windows OS version

Windows 10 v22H2

ImageGlass version

9.3.2.250

ImageGlass release

Classic

1️⃣ Steps to reproduce

ImageGlass is unpredictable. Sometimes, it writes its settings to %UserProfile%\AppData\Local\ImageGlass. At other times, it writes its settings to C:\Program Files\ImageGlass.

The following steps show the unpredictability:

  1. Install ImageGlass in C:\Program Files\ImageGlass (machine-wide installation).
  2. Run it for the first time and finish the Quick Setup.
  3. Open an image in File Explorer normally. Observe where ImageGlass stores its settings.
  4. Disable User Account Control (UAC) and restart the system.
  5. Log in with an account that has admin privileges.
  6. Open an image in File Explorer normally. Observe where ImageGlass stores its settings.
  7. Re-enable UAC.
  8. Run an app with admin privileges (e.g., Terminal, MultiCommander, or Visual Studio Code) and use it to open an image in ImageGlass. Observe where ImageGlass stores its settings.
  9. Open an image in a Sandboxie container. Observe where ImageGlass stores its settings.
  10. Install a copy of ImageGlass on a USB flash drive with a write-protection tab.
  11. Close the write-protection tab to make the drive write-protected.
  12. Run ImageGlass and observe where it stores its settings.

2️⃣ Actual behavior

  • 👍 In step 3, ImageGlass correctly stores its settings in %UserProfile%\AppData\Local\ImageGlass.
  • 👎🏻 In step 6, ImageGlass writes to C:\Program Files\ImageGlass.
  • 👎🏻 In step 8, ImageGlass writes to C:\Program Files\ImageGlass.
  • 👎🏻 In step 9, ImageGlass writes to C:\Program Files\ImageGlass.
  • 👎🏻 In step 12, ImageGlass stores its settings in %UserProfile%\AppData\Local\ImageGlass.

3️⃣ Expected behavior

  • In step 3, ImageGlass must stores its settings in %UserProfile%\AppData\Local\ImageGlass.
  • In step 6, ImageGlass must stores its settings in %UserProfile%\AppData\Local\ImageGlass.
  • In step 8, ImageGlass must stores its settings in %UserProfile%\AppData\Local\ImageGlass.
  • In step 9, ImageGlass must stores its settings in %UserProfile%\AppData\Local\ImageGlass.
  • In step 12, ImageGlass must check whether the settings exist; if yes, it must generate a warning, saying the settings cannot be changed. If no, it must refuse to launch, as it cannot store its settings anywhere.

4️⃣ Screenshots / Video / Sample image file

No response

5️⃣ Additional context

The problem comes from here: App.cs, lines 80-L86. ImageGlass checks where it can store its settings, and stores them in the first possible place. The installation directory takes precedence. This is wrong. Just because ImageGlass can store its settings somewhere doesn't mean it should.

ImageGlass can store its settings in Program Files in the following conditions, but it shouldn't:

  • When it inherits admin privileges from the parent process.
  • When User Account Control (UAC) is disabled.
  • When it is run in a sandboxing solution, e.g., Sandboxie Plus or Turbo.net

In addition, a portable instance of ImageGlass cannot write to its startup folder (even though it should) when it is write-protected.

The solution is simple: If a file called igconfig.portable.json exists in the app's startup folder, the app must run in portable mode. Otherwise, it must store its settings in AppData. This solution is more reliable than a write-access test.

skycommand avatar May 25 '25 08:05 skycommand