First of all, I realize this is a messy situation, but it's not of my design, and I'm just trying to help, and for that I need your help.
- App A is getting installed automatically via SMS installer under the Administrator account, not the PC owner's User account. App A has a registry key defined in
HKEY_LOCAL_MACHINE
hive. - After App A is installed, we want to edit the above mentioned registry key, to assign the User's
C:\Users\USER_ID\Documents\
folder (I'm told we don't don't know who the user is and don't have access to USER_ID during step 1). - I know all about UAC, Application Manifest, and
requestedExecutionLevel
. However, I'm told we can't expe开发者_运维知识库ct that all users will be in the Administrators group on their machine. - Solution must be backwards compatible with Windows XP as well.
I'm searching for options to get `C:\Users\USER_ID\Documents\' into the 'HKEY_LOCAL_MACHINE' hive under the above listed conditions.
I found this thread that might be related to a similar situation, but I don't fully understand it yet (so I will give credit to anyone that explain it better):
- Find out (read) logged in user in a cmd started as a different user
I also read something that rules out ClickOnce:
- Clickonce + HKEY_LOCAL_MACHINE
After App A is installed with admin privileges you are trying to run an additional script as the local user who does not have admin privileges . In order for your secondary script to write to the local machine key it will have to be run with administrative privileges ..period. That said, you have basically two choices:
1) Use the RunAs command to run the script with elevated privileges and have the user type in a admin username and password to run the script with elevated privileges.
2) This is the better way imo - Since SMS is being leveraged as the delivery tool, use its capability to detect and use local client configuration settings to write the key at the time of installation.
So basically the SMS package would have to be setup to run only when the local user logs on one time so that SMS can grab the current user and write it to a file somewhere.. after that is completed SMS can run a separate package as the admin (user will get prompted) to do the software install looking for the file containing the user and then consequently updating the local machine key to the correct user my document path.
Enjoy!
精彩评论