question

willsullivan avatar image
0 Votes"
willsullivan asked RLWA32-6355 commented

Configure another user's environmental variables?

We have an installer that's setting up a windows service that runs under a different user account, and it's going to be configured with some pretty sensitive values we'd like to protect as well as possible.

We'd like to store those values in the user's environment variables, but the user running the installer is not always going to be the user under which the service runs.

I'm not finding much information online about user A configuring environment values for user B. Is it possible?

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Bruce-SqlWork avatar image
1 Vote"
Bruce-SqlWork answered RLWA32-6355 commented

It’s doable. The variables are stored in the registery under the users profile/Environment. You will need to get Sid of the user so you can find their entries in the registers. Then you can update.

A better approach would be to create application registery entries, and set the permissions on them to the desired account.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

A potential problem with the environment variable approach is that if the applicable user account is not logged on when the installer runs then the account's profile may not be loaded and so the registry data would not be available. Working around this problem would require enabling the installer to logon the user account and load its profile.

1 Vote 1 ·