Syntax line problem with reg.exe


I am trying to load the default user profile with reg.exe and then apply a registry key. But I get a failure on applying the key. The hive is loading properly.

set-variable -name arr_Prog1 -visibility public -Scope Script-Value @(
“Execute-Process -Path “reg.exe” -Parameters “load HKU\ntuser.dat $env:SYSTEMDRIVE\users\default\ntuser.dat””, "Execute-Process -Path <code>&quot;reg.exe</code>" -Parameters <code>&quot;ADD</code>"HKU\ntuser.dat\SOFTWARE\Microsoft\Internet Explorer\Main<code>&quot; /v</code>"Start Page<code>&quot; /t REG_SZ /d</code>"http://www.intranet.xxxxxx/<code>&quot; /f</code>"",
“Execute-Process -Path “reg.exe” -Parameters “unload””`

And then calling it from:

<pre><code> foreach ( $Itemarr_Prog1 in $arr_Prog1 ) {

			invoke-expression $Itemarr_Prog1
	}					&lt;/code&gt;&lt;/pre&gt;

So the defaultuser.dat is loading successfully. But I get a failure while applying the registry key.

So the commandline:
Execute-Process -Path "reg.exe" -Parameters "ADD "HKU\ntuser.dat\SOFTWARE\Microsoft\Internet Explorer\Main" /v "Start Page" /t REG_SZ /d "" /f"

Is failing. What is incorrect in my command line or then creating the array?



To use quotes inside your parameters, you have to escape them first with a tick mark.

An overall better method would be to use Invoke-HKCURegistrySettingsForAllUsers
See page 54-55 of PSAppDeploymentToolkitAdminGuide.docx


There are a lot of reg command in batch and converting them to Invoke-HKCURegistrySettingsForAllUsers seems to longer. the batch file were done with reg.exe so seems to me better to find a way to run it properly in Posh.

I did some espace but the code here is not showing them properly…

My image with tick


I put the tick in my variable definition. But in the output they are not appearing. How may I make the tick appearing in the end commandline?