Syntax line problem with reg.exe

//Syntax line problem with reg.exe
Syntax line problem with reg.exe 2016-09-06T18:14:32+00:00

The Toolkit Forums General Syntax line problem with reg.exe

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

    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 "reg.exe” -Parameters "ADD“HKU\ntuser.dat\SOFTWARE\Microsoft\Internet Explorer\Main" /v“Start Page" /t REG_SZ /d“http://www.intranet.xxxxxx/" /f“”, `
    “Execute-Process -Path "reg.exe” -Parameters "unload“”`
    )

    And then calling it from:

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

    invoke-expression $Itemarr_Prog1

    } </code></pre>

    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

    • This topic was modified 1 year, 2 months ago by  Francois.
    • This topic was modified 1 year, 2 months ago by  Francois.
    • This topic was modified 1 year, 2 months ago by  Francois.
  • Brian
    Participant
    Post count: 42

    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

    • Francois
      Participant
      Post count: 101

      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…

      • This reply was modified 1 year, 2 months ago by  Francois.
    • Francois
      Participant
      Post count: 101

      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,

    • Francois
      Participant
      Post count: 101

      My image with tick

You must be logged in to reply to this topic.