Jump to content

Exporting registry branches with spaces using Reg.exe or Regedit.exe fails


Recommended Posts

Hi,

reading and writing single registry keys containing spaces using the AutoIt Registry Management functions is not my problem.

But, exporting a whole registry branch (e.g. "HKEY_LOCAL_MACHINE\SOFTWARE\has spaces") using regedit.exe/reg.exe within AutoIt code did not work.

(OS: Windows 7)

I tried a lot:

  • RunWait(@ComSpec & ' /k ' & 'regedit /a output.reg "HKEY_LOCAL_MACHINE\SOFTWARE\has spaces" ')
  • ShellExecuteWait("regedit.exe ",'/a output.reg "HKEY_LOCAL_MACHINE\SOFTWARE\has spaces" , "")
  • Run(@ComSpec & ' /k ' & 'reg.exe EXPORT "HKEY_LOCAL_MACHINE\SOFTWARE\has spaces" "output.reg " ' )
  • Executing a batch file with "Run" or "_RunDos" containing: regedit /a output.reg "HKEY_LOCAL_MACHINE\SOFTWARE\has spaces"
  • variants with double quotes instead of single quotes
  • etc.

Execution from a shell always worked!

Using a registry branch without spaces always worked!

I guess, adding reg-files with reg.exe or registry.exe fails similarly (without testing it)

 

My way out was using PsExec from SystemInternals:

  • $exitCode = RunWait('PsExec -s -i -h regedit.exe /a output.reg "HKEY_LOCAL_MACHINE\SOFTWARE\has spaces" ', @SW_HIDE )

Pretty uncomfortable, i guess, but maybe one of you guys can prove me wrong or has a better idea :P.

Thx,

Holgh

 

 

Link to comment
Share on other sites

No problems for me using this one:

RunWait(@Comspec & ' /k reg EXPORT "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Action Center" export.reg',@ScriptDir)

 

Edited by spudw2k
Link to comment
Share on other sites

Thx for your immediate reply.

You're right, it has nothing to do with space characters in the registry branch.

Instead, when testing out my " HKEY_CURRENT_USER\Software" registry folder, there a some sub-folders which I can read out. With others, the command above could not find the registry key/value according to the return message.

But these ones work, when using the reg command in the command shell.

Access rights?

Link to comment
Share on other sites

I found out, that I get different registry exports depending on using:

RunWait(@Comspec & ' /k reg EXPORT "HKLM\Software" export.reg',@ScriptDir)

RunWait(@Comspec & ' /k reg EXPORT "HKEY_LOCAL_MACHINE\Software" export.reg',@ScriptDir)

and executing

reg EXPORT "HKEY_LOCAL_MACHINE\Software" export2.reg

in a command shell.

Link to comment
Share on other sites

Just for completion of this thread, this call works

(32-bit AutoIt on 64-Bit OS accessing 64-Bit registry key using reg.exe - with or without spaces in key ^_^):

RunWait(@Comspec & ' /c reg EXPORT "HKY_LOCAL_MACHINE\Software\has spaces" export.reg /reg:64',@ScriptDir)

 

More info:

https://support.microsoft.com/en-us/kb/948698

https://support.microsoft.com/en-us/kb/305097

 

Thx again for your help!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...