2019-10-18

Missing a persistent SCITE_USERHOME environment variable ?

PROBLEM / SYMPTOM: The scintilla-based Text Editor does not save sessions, latest files, nor any configuration. At each start the environment is pristine.

CONTEXT / BUG: SciTE was installed using Chocolatey AS AN ADMINISTRATOR, but is used by a standard user.

$ choco install -y autoit --version 3.3.14.5
$ choco install -y scite4autoit3 --version 19.102.1901.001 


Reference


SciTE utilities look for an env variable called SCITE_USERHOME and when that is missing will assume a portable installation of SciTE:

Fix, Part 1: Create missing directory


If you are not running as a standard user and have a different account for administration, you might notice that a directory "C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE" was created but not "C:\Users\StandardUser\AppData\Local\AutoIt v3\SciTE"... So the first thing to do is to fix that directory:

cmd /c "mkdir "%UserProfile%\AppData\Local\AutoIt v3\SciTE" & pause"


Fix, Part 2: Create user's environment variable

REG_SZ


cmd /c "setx SCITE_USERHOME "%UserProfile%\AppData\Local\AutoIt v3\SciTE" & pause"

This command is the correct one, and we could stop right here. But out of curiosity, let's see how we could make a dynamic variable.

REG_EXPAND_SZ


In order to use REG_EXPAND_SZ type variables, we'd have to use the REG.EXE utility. It takes a little bit of escaping to pass the "percent" characters to the command, but this is how it would look:

cmd /c "REG ADD HKCU\Environment /v SCITE_USERHOME /t REG_EXPAND_SZ /d ^%UserProfile^% & pause"

Additional information


Missing a persistent environment variable ?


Registry hives and paths

  • User Variables: HKEY_CURRENT_USER\Environment
  • System Variables: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment 



ALTERNATIVE FIX

Use an Administrator account and give the rights on "C:\Program Files (x86)\AutoIt3\SciTE" for the standard user. This will do if there is only one person needing to use the program.


No comments:

Post a Comment