reg.exe throws an error on success in remote session

Welcome Forums General PowerShell Q&A reg.exe throws an error on success in remote session

This topic contains 6 replies, has 2 voices, and was last updated by

GS
 
Participant
9 months, 3 weeks ago.

  • Author
    Posts
  • #91961
    GS

    Participant
    Points: 1
    Rank: Member

    Hello,

    Seeing oddity below when executing reg.exe remotely. Despite message that it's completed successfully it still throws an error

    PS C:\Users\admin> Enter-PSSession containerhost1
    [containerhost1]: PS C:\Users\admin\Documents> reg export hklm\software\odbc\odbc.ini a.reg
    The operation completed successfully.

    [containerhost1]: PS C:\Users\admin\Documents> reg import a.reg
    reg : The operation completed successfully.
    + CategoryInfo : NotSpecified: (The operation completed successfully.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

  • #91964

    Keymaster
    Points: 1,619
    Helping HandTeam Member
    Rank: Community Hero

    Is the second one attempting to write to HKCU, by chance?

  • #91966
    GS

    Participant
    Points: 1
    Rank: Member

    No. I exported something from HKLM in `reg export` right above it.

  • #91969

    Keymaster
    Points: 1,619
    Helping HandTeam Member
    Rank: Community Hero

    Ah, gotcha.

    It's probably still HKCU related, because you don't get a proper HKCU in a remote session. It's likely reg.exe is just hardcoded to do something that isn't going to work in that context.

    • #91972
      GS

      Participant
      Points: 1
      Rank: Member

      The problem that it throws an error at all, so when I build docker images it breaks the flow, how do I structure powershell call that no stderror is returned?

  • #91975

    Keymaster
    Points: 1,619
    Helping HandTeam Member
    Rank: Community Hero

    Huh. You could try redirecting the error pipeline into the success pipeline, and then piping the command to Out-Null. That should keep anything out of stderr.

  • #91978
    GS

    Participant
    Points: 1
    Rank: Member

    Thanks. This works reg import a.reg *>&1 | out-null

The topic ‘reg.exe throws an error on success in remote session’ is closed to new replies.