Thursday, August 9, 2012

Squirrel SQL – cannot update on Windows with UAC enabled

I had this problem before but I just worked around it by simply copying the updated installation from a Windows machine that didn’t have User Account Control (UAC) enabled – with SQuirrel SQL 3.4.0 update now available, thought I might look into it and see what’s causing the problems. Sure, if you are installing SQuirrel SQL into a folder somewhere that doesn’t require elevation, you should not have this problem – thing is I usually install it on Windows servers with UAC enabled and place it in %ProgramFiles%.

First of all, obviously, you need to first run SQuirrel SQL elevated (right click > Run As Administrator), otherwise when using the update feature it will fail promptly, as it wants to download the updated .jars into a subfolder of Squirrel SQL home.




Running Squirrel SQL as Administrator this time, will download the updates just fine.



Now the problem is, if you close and restart SQuirrel SQL not elevated, it will prompt to install the updates, but will fail as it doesn’t have the rights to update the libraries.

If you run it elevated though, it won’t prompt you to install the updates!!! Now that’s annoying…

Process Monitor to the rescue (again) showing that SQuirrel SQL is looking for the listing file in %WINDIR%\System32\update ?! Odd alright… The javaw.exe process in Process Explorer shows something that explains it: the current directory of the elevated process is not the one specified in the shortcut, but %WINDIR%\System32 !



Looking at squirrel-sql.bat it seems to prepare the home location into a UPDATE_PARMS environment variable, but maybe it’s not used by the application and it should be really added to the command line?!

The quick solution is to add a change-directory command to the SQuirrel SQL home - that way it will work when running under normal privileges (the same working directory is coming from the shortcut), as well as when running elevated (when current directory is %WINDIR%\system32).
SET UPDATE_CP=%TMP_CP%
SET UPDATE_PARMS=--log-config-file "%SQUIRREL_SQL_HOME%\update-log4j.properties" --squirrel-home "%SQUIRREL_SQL_HOME%" %1 %2 %3 %4 %5 %6 %7 %8 %9
cd /d "%SQUIRREL_SQL_HOME%"
"%LOCAL_JAVA%" -cp %UPDATE_CP% -Dlog4j.defaultInitOverride=true -Dprompt=true net.sourceforge.squirrel_sql.client.update.gui.installer.PreLaunchUpdateApplication %UPDATE_PARAMS%
I’ve added my findings to a related ticket:
https://sourceforge.net/tracker/index.php?func=detail&aid=2759952&group_id=28383&atid=393414

Update:

D’oh! now I see it, thanks to Notepad++ word highlight feature! The environment variable is defined as UPDATE_PARMS, but the one in the command line is UPDATE_PARAMS! so I guess now you have two solutions :-)

2 comments :

  1. Thank you for this post. Changing UPDATE_PARMS to UPDATE_PARAMS solved the problem for me!

    ReplyDelete