13 Replies Latest reply on Jan 29, 2008 5:29 PM by rdm

    Deleting Registry Key from HKEY_CURRENT_USER


      I'm required to update a value in the HKEY_CURRENT_USER and I have tried updating this by packaging the update as a msi and also by importing the registry settings as a reg file. When I try to push this out with LANDesk, the setting is not changed as the system uses the local system account to apply the changes. Does anyone know how to get around this problem?

        • 1. Re: Deleting Registry Key from HKEY_CURRENT_USER
          Jed Employee

          You'll have to create a batch file to call \program files\landesk\ldclient\STARTASUSER.exe.  This will run any file as the locally logged on user.  This will help you:






          1.create a .bat file to import the registry key file on the client, suppose this registry key file is named "Myfile.reg"




          2.Create bat file, please refer the following script:




          @echo off


          regedit /s Myfile.reg





          the "Myfile.reg" file as an additional file so that we don't need to

          specify the path of "Myfile.reg" in the batch file. The .reg file will

          be downloaded to the same location as the .bat file in the SDMCACHE

          directory on the client.




          4. Schedule the task on target client machine.





          Registry changes made as local system will not touch the

          HKEY_CURRENT_USER hive. If the registry key to be imported is in the

          HKEY_CURRENT_USER hive, then local system will not be able to make the

          change. Use the runasuser.exe instead to import a user specific

          registry key.







          Message was edited by: Jed


          The spaces didn't show for me...  Hopefully fixed.

          • 2. Re: Deleting Registry Key from HKEY_CURRENT_USER
            Jared Barneck SupportEmployee



            Edit your post and delete all the useless spaces.


            Put the batch file surrounded by code tags:


            Your batch file

            • 3. Re: Deleting Registry Key from HKEY_CURRENT_USER
              Jared Barneck SupportEmployee

              This is actually one of the few reasons to still use package builder (though package builder doesn't work on Vista)


              It has a nice registry tool that has an option to apply to "All users" so any user that has ever logged in will get the registry key in their HKCU.

              1 of 1 people found this helpful
              • 4. Re: Deleting Registry Key from HKEY_CURRENT_USER
                Fabian Schmidt Expert





                Perhaps it is better to use the STARTASUSER.EXE command given from LANDesk under %programfiles%\LANDesk\LDClient with the associated switches, most likley ///silent.



                But the problem will be that the User currently logged on needs local admin rights to write into the registry.



                Another method would be the shareware tool runaspc.exe there you are able to give the right user and a password for this user and the user isn't able to get the password. Until now I don't have any experience with the runaspc.exe, I only know this tool exists.



                For that issue there's a lot of testing required.






                • 5. Re: Deleting Registry Key from HKEY_CURRENT_USER
                  zman Master

                  Users should have full rights to HKCU.  Also I think if you just write the key to the .default portion it will carry down to all new users (I think this is what PB does). Since PB is on its death bed, there are a couple of Autoit functions that work very well (can be used for HKLM where rights may be an issue and Startasuser will not work).







                  • 6. Re: Deleting Registry Key from HKEY_CURRENT_USER
                    phoffmann SupportEmployee

                    Seconding the suggestion for STARTASUSER - you can then launch a batch/script whatever, and ensure it'll run in user context.


                    The only thing to watch out for is not to launch this job while no-one is logged on to the machine (where I seem to recall STARTASUSER simply falls back to the LOCAL SYSTEM account - hence modifying the HKLM registry hive).


                    But if you make this as a policy for users (for instance), then using STARTASUSER will definitely make your life easier to ensure that this will get launched in the right user's context :).


                    Paul Hoffmann

                    LANDesk EMEA Technical Lead

                    • 7. Re: Deleting Registry Key from HKEY_CURRENT_USER
                      Jared Barneck SupportEmployee

                      I cannot believe I am saying this, but Package Builder, in this instance, is probably a better solution for XP (NOT VISTA) than StartAsUser.exe.


                      StartAsUser.exe has two limitations.


                      1. It can only change/add the Registry key for one user at a time.

                      2. It can only change/add the Registry key if the user is logged in.


                      So if there are five or more users who use the same machine, the package would have to run 5 times, once when each separate user is logged in.  Some sites (Call centers) do not have set computers and a different user could log into a computer every day.


                      Package builder can add a registry so simply. 


                      This little configuration adds a new Registry Key called "New Key".

                      It creates one DWORD called Smile that is set to a value of 1.


                      KEY: new, "HKEY_CURRENT_USER\Software\New Key"
                      VALUE: reg_dword, new, "Smile", "1"


                      This will work on XP, 2000/2003, ME, 9x.  It will work regardless of who is logged in.  It has only one problem, it will not run on Vista.

                      • 8. Re: Deleting Registry Key from HKEY_CURRENT_USER


                        Many thanks to all who answered my question. We tried the Package Builder method and found that it worked a treat. This was my first experience using the LANDesk community and found all the responses top notch. Thanks again to all.






                        • 9. Re: Deleting Registry Key from HKEY_CURRENT_USER



                          LANDesk Management Suite 8.8 provides the ability to run packages as the logged on user without using the startasuser.exe application, it is built right into the GUI. You can set this on the distribution package properties. You can either set the package to run as Local Syste (as it always has) or as the current user's account.

                          • 10. Re: Deleting Registry Key from HKEY_CURRENT_USER
                            WiseGuy Apprentice


                            Another way to do updates to new and existing users' profile folders and/or HKCU is to use Active Setup. Active Setup is the mechanism the Microsoft uses to update user specific items for their applications (i.e. Internet Explorer, Media Player, etc) that have many user specific settings.   We've used it many times and it's been a lifesaver and is basically set and forget.  The best part is that it doesn't matter if the person logging in is an existing user or a brand new user.  Active setup will run once, and only once for each user.






                            See the following for a great explanation on using Active Setup.






                            • 11. Re: Deleting Registry Key from HKEY_CURRENT_USER
                              rdm Apprentice

                              there's one more limitation that I found:  you cannot run something that is located on a server, whatever you're going to run has to be a local file


                              for example, this won't work:  push a batch file via SWD that looks like this: 

                              "c:\program files\landesk\ldclient\startasuser.exe" 


                              I could be wrong, because I just started testing using startasuser, but it wouldn work for me

                              • 12. Re: Deleting Registry Key from HKEY_CURRENT_USER
                                Jared Barneck SupportEmployee

                                That should be a permissions issue and not a limitation of StartAsUser.exe.

                                • 13. Re: Deleting Registry Key from HKEY_CURRENT_USER
                                  rdm Apprentice

                                  I meant that as more of a tip ... I don't think it's a problem with startasuser.