PDA

View Full Version : Reminder: Never write to HKEY_CURRENT_USER from an elevated application



NewsArchive
09-30-2009, 01:59 AM
Still one of the most-asked questions we get via email is from developers
asking how they can write from the installer to HKEY_CURRENT_USER.

An application that is running elevated ("requireAdministrator" manifested)
should never write to HKEY_CURRENT_USER. Only "asInvoker" applications
should write to that registry key.

Because a typical installation program always has to run with administrator
execution level privileges, you can't write to the correct HKEY_CURRENT_USER
profile.

Let us assume, you have a "JoeUser" Standard User account under Vista or
Windows 7. Installation applications always run elevated -- an elevated
process is usually one that has been launched by someone with a Full
Administrator Token and runs with High Integrity Level Privileges
(administrator execution level privileges). If "JoeUser" starts the
installation, UAC determines that the Current User does not have a token of
sufficiently high Integrity Level and the Credentials Prompt asks the user
to provide a username and password of someone who has sufficient rights.
Windows will then create the necessary token for that user and uses it to
elevate the process so you can now continue with the installation. Please
note that you are on a completely different profile after the elevation.
You have switched from the "JoeUser" profile to the "Administrator" profile!
In other words, you do not write to the "JoeUser" HKEY_CURRENT_USER registry
key but to the Administrators key.

What you can do is the following: you create a simple "asInvoker" helper
application with SetupBuilder (or Clarion, or Visual Studio, or whatever).
This helper application can write to HKEY_CURRENT_USER -- you start that
helper from your elevated running installer with the "Launch non-elevated
under UAC" Run Program option.

Or even better, write to HKEY_CURRECT_USER directly from your own (asInvoker
manifested) application.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder is Windows installation -- "point. click. ship"

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
10-03-2009, 03:31 AM
BTW Friedrich after updating I again lost all my script functions "paragraphs" (line in green)
I again had to uninstall and reinstall to get them back as normal
I tried a repair option but did not repair

for info(...my machine again ;) )


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:45 AM
> BTW Friedrich after updating I again lost all my script functions
> "paragraphs" (line in green) I again had to uninstall and reinstall
> to get them back as normal I tried a repair option but did not
> repair
>
> for info(...my machine again ;) )

To be honest, I have absolutely no idea where to look in the source code.
It's just a simple Clarion QUEUE that displays the functions. And you are
the only user with this problem :-( So I fear it's "machine specific".

Friedrich

NewsArchive
10-05-2009, 01:45 AM
I have the functions what I miss are the green "seperator-header" lines.... if this can help


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:46 AM
> I have the functions what I miss are the green "seperator-header"
> lines....
> if this can help

Unfortunately, no. It does not help :-(

This is the original Clarion source code:

! ---

FunctionQueue:Command = 'Script Management'
DO FunctionQueueSpecialColor
ADD(FunctionQueue)

FunctionQueue:Command = ''
DO FunctionQueueSpecialColor
ADD(FunctionQueue)

FunctionQueue:Command = ' Add Script Comment...'
DO FunctionQueueNormalColor
DO AddFunctionQueue

And so on.

! ---

The "FunctionQueueSpecialColor" reoutine sets the item to green, the
"FunctionQueueNormalColor" routine sets it back to black. There is nothing
I could think of that I would "remove" the "seperator-header" lines.

Friedrich

NewsArchive
10-05-2009, 01:46 AM
FunctionQueueSpecialColor ROUTINE

IF MachineName <> 'JP'
ELSE
work
END

I knew it Friedrich :)


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:47 AM
> FunctionQueueSpecialColor ROUTINE
>
> IF MachineName <> 'JP'
> ELSE
> work
> END
>
> I knew it Friedrich :)

Hahahaha... If it would be that easy <g> I would really love to fix this
problem -- but I don't know where to start looking :-( The source code that
fills the QUEUE is so darn simple.

Friedrich

NewsArchive
10-05-2009, 01:47 AM
I know .....
what we could do when we both have time is a debugging session here with TeamViewer...but is is worth it ....

no real pb : I uninstall - reinstall and change the signtool.exe


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:48 AM
> I have the functions what I miss are the green "seperator-header" lines.... if this can help

Maybe it is just a monitor thing (or your color blind for that shade of
green<g>).

Do you have blank spaces where the green lines should be?

JAT...

Charles




--
-------------------------------------------------------------------------------------------------------
Charles Edmonds
www.clarionproseries.com - "Get ProPath, make your Clarion programs ready
for Windows 7 and Vista!"
www.ezchangelog.com - "Free ChangeLog software to manage your projects!"
www.setupcast.com - "A revolutionary new publishing system for software
developers - enhanced for SetupBuilder users!"
www.pagesnip.com - "Print and Save the Web, just the way you want it!"
www.clarionproseries.com - "Serious tools for Clarion Developers"
www.ezround.com - "Round Corner HTML tables with matching Banners, Buttons
and Forms!"
www.lansrad.com - "Intelligent Solutions for Universal Problems"
www.fotokiss.com - "World's Best Auction Photo Editor"
-------------------------------------------------------------------------------------------------------

NewsArchive
10-05-2009, 01:49 AM
>
> Do you have blank spaces where the green lines should be?
>

JP posted a screenshot some time ago.

http://www.lindersoft.com/forums/showthread.php?p=37689#post37689

But I can't think of anything in the source code that would cause this.

Friedrich

NewsArchive
10-05-2009, 01:50 AM
No Charles all functions are there no empty lines
seems the colorline routine does not trigger properly here

BUT only when I update SB7

Clean install is fine

and my glasses are not greenpeace haters either ;)


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:50 AM
> BUT only when I update SB7
>
> Clean install is fine

And that is even more strange. The FULL INSTALL (including the full install
in maintenance mode to update an existing package) and the WEB UPDATE
process install the very same DLLs and EXE.

Friedrich

NewsArchive
10-05-2009, 01:51 AM
That is why it IS my machine or 2008 ent srv or ..... well no big hassle.... just wanted you to know


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:51 AM
oh NO : I have lost them again.....
no update nothing just close and reopen IDE

:(



Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:52 AM
> oh NO : I have lost them again.....
> no update nothing just close and reopen IDE
>
> :(

This is the source code:

FunctionQueue:Command = 'Script Management'
DO FunctionQueueSpecialColor
ADD(FunctionQueue)

FunctionQueue:Command = ''
DO FunctionQueueSpecialColor
ADD(FunctionQueue)

FunctionQueue:Command = ' Add Script Comment...'
DO FunctionQueueNormalColor
DO AddFunctionQueue

Where:

FunctionQueueNormalColor ROUTINE
FunctionQueue:NormalFG = COLOR:NONE
FunctionQueue:NormalBG = COLOR:NONE
FunctionQueue:SelectedFG = COLOR:NONE
FunctionQueue:SelectedBG = COLOR:NONE

FunctionQueueSpecialColor ROUTINE
FunctionQueue:NormalFG = COLOR:Green
FunctionQueue:NormalBG = COLOR:NONE
FunctionQueue:SelectedFG = COLOR:NONE
FunctionQueue:SelectedBG = COLOR:NONE

The creates the QUEUE and displays it in a LIST.

I don't see anything in that code that could cause this :-( The sb7.exe IDE
is compiled with Clarion 6.3 Build 9056

Friedrich

NewsArchive
10-05-2009, 01:53 AM
when is this Q creation done pls ? so as to try and force it ?


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF


DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:53 AM
>
> when is this Q creation done pls ? so as to try and force it ?
>

After you opened a project. If you close the project, the QUEUE is freed.
If you open it again, it's created.

Friedrich

NewsArchive
10-05-2009, 01:54 AM
FOUND :)

Sort functions alpha.....idiot me !



Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:54 AM
well now you know what to answer ;)


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:55 AM
Don't you hate it when the computer does what you tell it to do??? <G>

Jane

NewsArchive
10-05-2009, 01:55 AM
I hate it when I am dumb enough to ask for a settting and not 'think' that it affects displaying of what it is supposed to do

Think more - work less ;)


Merci

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

DMC - Data Management Center
A tool to let you Migrate Import Export Transfer your Data
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" &
"Works with Windows Server 2008"

NewsArchive
10-05-2009, 01:55 AM
> FOUND :)
>
> Sort functions alpha.....idiot me !

<G> :-)

Friedrich