Convert .reg file and push values under default profile

//Convert .reg file and push values under default profile
Convert .reg file and push values under default profile 2016-07-16T02:07:04+00:00

The Toolkit Forums General Convert .reg file and push values under default profile

  • Author
    Posts
  • Francois
    Participant
    Post count: 101
    #1462 |

    Hi,

    I have a .reg file with many values. How should I script it to take the different key and values and pushing it to the default profile?

    THanks,

  • That_annoying_guy
    Participant
    Post count: 42

    That great for NEW users on the machines. What about existing users?

    Consider using Set-ActiveSetup

    If all the REG changes go to HKCU you should be able to something like this:

    Set-ActiveSetup -StubExePath “$envWinDir\regedit.exe” -Arguments “/S "%SystemDrive%\Program Files (x86)\PS App Deploy\PSAppDeployHKCUSettings.reg“” -Description ‘PS App Deploy Config’ -Key ‘PS_App_Deploy_Config’ -ContinueOnError $true

    • Francois
      Participant
      Post count: 101

      Hi,

      With regedit /s …reg there is an annoying window from the Windows security will set-activesetup doing better?

      Thanks,

  • That_annoying_guy
    Participant
    Post count: 42

    Sorry, I meant something like this:

    Set-ActiveSetup -StubExePath “$envSystem32Directory\reg.exe” -Arguments “import "%SystemDrive%\Program Files (x86)\PS App Deploy\PSAppDeployHKCUSettings.reg“” -Description ‘PS App Deploy Config’ -Key ‘PS_App_Deploy_Config’ -ContinueOnError $true

    I took original from the .EXAMPLE in the Set-ActiveSetup. I will have to ask the Developers to update it.

    The catch is that your REG file can only have entries for HKEY_CURRENT_USER. If you have HKEY_LOCAL_MACHINE entries in your REG file, they must be separated and imported during the install of the program.

  • Francois
    Participant
    Post count: 101

    Hi,

    So:
    Set-RegistryKey–> Set registry but not from a reg file.
    Set-ActiveSetup–> To use a .reg file and then set on HKCU from active setup
    Invoke-HKCURegistrySettingsForAllUsers –> To set HKCU from HKU hive and will set default user as already create user and future user. But does not support .reg file. This one would be insteresting by just reading . reg file and set the value.

    Thanks,

    François

  • That_annoying_guy
    Participant
    Post count: 42

    None support .reg files directly and there is no converter at this time.

    Set-RegistryKey affects one registry value at a time. In your case, if you have HKEY_LOCAL_MACHINE entries in your REG file, you must use this at install time.

    ActiveSetup is a built-in feature of Windows that triggers an EXE to make per-user changes when a user logs in. The EXE is triggered ONCE and delays the showing of the desktop until it is done or fails. If it fail you will get no error message. If the EXE hangs or takes a long time to finish, you will think your computer is hung. Set-ActiveSetup creates the required registry keys in “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components” to make ActiveSetup to work. When a user logs in, the OS reads those sub-keys and creates a matching key name in “HKEY_CURRENT_USER\SOFTWARE\Microsoft\Active Setup\Installed Components”.

    In your case, that EXE is REG.exe and you give reg.exe parameters. Just make sure that a regular user has the permissions to make those changes. The EXE file (and reg file in your case) must be reachable when the user logs in. If the regular user cannot run/read the file, it will fail. So a more complete code sample would be:

    <code>#Copy the REG file on the machine
    Copy-File -Path &quot;$dirFiles\PSAppDeployHKCUSettings.reg&quot; -Destination &quot;$envProgramFilesX86\PS App Deploy\PSAppDeployHKCUSettings.reg&quot; -ContinueOnError $false
    #prepare ActiveSetup
    Set-ActiveSetup -StubExePath &quot;$envSystem32Directory\reg.exe&quot; -Arguments &quot;import &lt;code&gt;&amp;quot;$envProgramFilesX86\PS App Deploy\PSAppDeployHKCUSettings.reg&lt;/code&gt;&quot;&quot; -Description &#039;PS App Deploy Config&#039; -Key &#039;PS_App_Deploy_Config&#039; -ContinueOnError $true</code>

    Invoke-HKCURegistrySettingsForAllUsers take a more aggressive way of doing per-user changes. It locates all NTUSER.DAT files (Each user’s HKCU) and forces the changes in at install time. For future users, it modifies the Default user profile. I don’t like this route because I see it as pollutes the Default user profile. You could, in theory, make a change that makes new user profiles unusable.

    The PSAppDeploymentToolkitAdminGuide.docx does mention some of this but it assumes you know what ActiveSetup is and how it works.

  • Francois
    Participant
    Post count: 101

    Hi,

    The downside of reg.exe or regedit is the UAC. When we are running regedit or reg there is a command window appearing and it takes a time before running. It will but it takes time. So there is a possibility a user would just close the window.

    Yes, I know Active setup. Personnally, I believe all whose scenarios are usefull.

    1. When configuring a new computer Invoke-HKCURegistrySettingsForAllUsers will make ready a computer for everyone for HKCU.
    2. Set-RegistryKey is good for new computers and for change during software installation
    3. Set-ActiveSetup is usefull to configure diverses user components. But the UAC might be a problem while changing HKCU with reg.exe or regedit as it might takes time. Is it a way to make it run minimize or hidden?

    Thanks,

    • This reply was modified 1 year, 3 months ago by  Francois.
  • That_annoying_guy
    Participant
    Post count: 42

    I can’t reproduce the UAC prompt with reg.exe import <path to .reg file>
    I tried on 3 computers in 3 different environments.

    In one of our environments REG/Regedit is disabled for normal users but no UAC prompt.
    So we usually launch a WiseScript exe that does registry the changes.

    I’m sorry. I can’t help you.
    You must find a way that a regular user can change their HKCU and use that in ActiveSetup.

    • Francois
      Participant
      Post count: 101

      Hi,

      With Active Setup it will work… but a window is appearing and after a time the job will be done but before that, if you click on the Window, the prompt will appear.

      Wise? Who is still using Wise? 🙂

      Thanks,

  • That_annoying_guy
    Participant
    Post count: 42

You must be logged in to reply to this topic.