This project is read-only.

Set-ActiveSetup Not Working

Topics: Archive - Toolkit Extensions
Mar 20, 2015 at 4:29 PM
Edited Mar 20, 2015 at 4:32 PM
I believe the Set-ActiveSetup function is not working properly. I have tested multiple ways and cant seem to have it properly create the registry entries. I am testing on a x64 system and have validated that the entries are not showing up in either standard registry paths, mentioned in the deployment guide, or the SysWOW64 registry paths?

I have written them from scratch according to the guide and also copied and pasted directly from the examples and in all cases they were not created. I am using the 3.6.0 version of the code, fresh download with no changes.

Here are some examples of what I have tried:
Set-ActiveSetup -StubExePath 'regedit.exe' -Arguments '/S "%SystemDrive%\Program Files (x86)\DataLink Viewer 11\DesChampsLive_DataLink_Viewer.reg"' -Description 'Setup Personalized Settings for DataLink Viewer' -Key 'DataLinkViewer_ODBC_UserSetup' ContinueOnError
Set-ActiveSetup -StubExePath 'regedit.exe /S "%SystemDrive%\Program Files (x86)\DataLink Viewer 11\DesChampsLive_DataLink_Viewer.reg"' -Description 'Setup Personalized Settings for DataLink Viewer' -Key 'DataLinkViewer_ODBC_UserSetup' ContinueOnError
Just wanted to make sure someone is aware of the potential issue.
Mar 20, 2015 at 4:43 PM
Does the active set up registry entry get created under this path?: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\

If so, then Set-ActiveSetup is working correctly and the problem is with the way you are importing registry entries with regedit.exe. Active setup entries are only execute against a user account when they first log into their system. Therefore, active setup only has standard user rights. Please make sure that the registry setting you are importing are all HKEY_CURRENT_USER registry keys or the command will fail. Also, some companies restrict the ability of standard users being able to execute regedit.exe so your command would also fail in this scenario. That is why reg.exe is usually a better option for importing/creating registry keys.

Also, you can take a look at the Invoke-HKCURegistrySettingsForAllUsers function for another method of importing HKEY_CURRENT_USER settings for all users.
Mar 20, 2015 at 4:48 PM

No it does not get created in that path either. I have been using Active Setup for some time now with this tool, and coding it directly as needed in my CMD or VBS deployment files. Thanks for the tip on the REG vs REGEDIT but at this point REGEDIT does work in my environment quite nicely.

Set-ActiveSetup does NOT appear to be working in any of my tests, does it work for you?. I had been using version 3.5.0 for some time and had a work around for creating this key. It does work nicely but the Set-ActiveSetup function will be much easier to manage going foward.

Here is what I have been using all along as a work around. No issues are found with this method:
Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\DataLinkViewer_ODBC_UserSetup' -Name 'Version' -Value '1' -Type String
Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\DataLinkViewer_ODBC_UserSetup' -Name 'StubPath' -Value 'regedit.exe /S "%SystemDrive%\Program Files (x86)\DataLink Viewer 11\DesChampsLive_DataLink_Viewer.reg"' -Type ExpandString
Mar 20, 2015 at 5:15 PM
Can I see your log file for the install so I can examine the log entries from when this functions is executed?
Mar 20, 2015 at 5:20 PM
Also, I notice that your Set-ActiveSetup command has "ContinueOnError" in it. It should actually be "-ContinueOnError $true" or "-ContinueOnError $false".
Mar 20, 2015 at 6:23 PM
Thanks! I did update the testing code to include -ContinueOnError $true but the function still did not work. I have been using ContinueOnError in a few other scripts and it seemed to work well but I will use it the way you suggested going forward.

FYI, I have tested on 3 other machines and all have failed as well. Use the PM that I sent you for a link to the log file. It was executed with the following code:
Set-ActiveSetup -StubExePath 'regedit.exe /S "%SystemDrive%\Program Files (x86)\DataLink Viewer 11\DesChampsLive_DataLink_Viewer.reg"' -Description 'VA Database ODBC Setup' -Key 'DataLinkViewer_ODBC_UserSetup' -ContinueOnError $true
Mar 20, 2015 at 8:49 PM
Edited Mar 20, 2015 at 8:54 PM
I ran the Set-ActiveSetup command you shared above and the my log file showed me this error:
[Pre-Installation] :: Failed to set Active Setup registry entry. 
Error Record:

Message        : Exception calling "GetExtension" with "1" argument(s): "Illegal characters in path."
InnerException : System.ArgumentException: Illegal characters in path.
                    at System.IO.Path.GetExtension(String path)
                    at CallSite.Target(Closure , CallSite , RuntimeType , Object )

FullyQualifiedErrorId : ArgumentException
ScriptStackTrace      : at Set-ActiveSetup<Process>, 
                        D:\Development\psappdeploytoolkit\Toolkit\AppDeployToolkit\AppDeployToolkitMain.ps1: line 7987
                        at <ScriptBlock>, D:\Development\psappdeploytoolkit\Testing\Deploy-Application.ps1: line 111
                        at <ScriptBlock>, <No file>: line 1

PositionMessage : At D:\Development\psappdeploytoolkit\Toolkit\AppDeployToolkit\AppDeployToolkitMain.ps1:7987 char:4
                  +             [string]$StubExeExt = [System.IO.Path]::GetExtension($StubExePath)
                  +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error Inner Exception(s):

Message        : Illegal characters in path.
InnerException : 
Looking at your command again, you have the wrong path for -StubExePath. That parameter should only have the path of the file you wish to execute. Then use the -Arguments parameter to pass the -StubExePath any other options. Therefore, your command should look like this:
Set-ActiveSetup -StubExePath "$envWinDir\regedit.exe" -Arguments "/S `"%SystemDrive%\Program Files (x86)\DataLink Viewer 11\DesChampsLive_DataLink_Viewer.reg`"" -Description 'VA Database ODBC Setup' -Key 'DataLinkViewer_ODBC_UserSetup' -ContinueOnError $true