holgh

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

9 posts in this topic

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

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

(:

RunWait('regedit.exe /e "' & @ScriptDir & '\File.reg" "HKEY_CURRENT_USER\Software\AutoIt v3"')

 


Regards,
 

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Are you running a 32 or 64 bit OS?  Are you running 32 or 64 bit AutoIt?  

 

Adam

1 person likes this

Share this post


Link to post
Share on other sites

Mea Culpa,

you had the right instinct AdamUL.

32Bit AutoIt on a 64Bit OS ==> registry confusion

Thx alot!

Share this post


Link to post
Share on other sites

Your welcome.  As soon as I seen that you got different results, that was my first thought.  Glad I could help.  

 

Adam

Share this post


Link to post
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!

Share this post


Link to post
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