Syntax line problem with reg.exe

Hi,

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 "http://www.intranet.education/" /f"

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

Thanks,

François

To use quotes inside your parameters, you have to escape them first with a tick mark.
See http://ss64.com/ps/syntax-esc.html

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

Hi,

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

Hi,

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?

Thanks,