Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to import a registry file by running regedit. The problem is that the powershell script has to run from a 32 bit executable, but I want to run the 64 bit regedit. Any ideas on how I can force the use of the 64 bit regedit?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

If you explicitly call the executable in the windows directory, you will get the system native version. If you do not specify an absolute path, you will get the WOW64 version.

This will always open 32 bit:

Start-Process regedit

This will open the 64 bit version when on x64, or the 32 bit version when running on a 32 bit machine:

Start-Process "$env:windir\regedit.exe"

If you only want your script to execute on 64 bit, you can detect your running architecture, by checking $env:Processor_Architecture and error out when it doesn't meet your requirements.

Note: This works because 'regedit.exe' is stored in your Windows directory. If you want to access a 64-bit application from a 32-bit context, and the application happens to be in System32 instead, you can use $env:windir\sysnative\<APPLICATION>. $env:windir\sysnative gives you the 64-bit System32 instead of the redirect to SysWOW64.

share|improve this answer
    
I tried to use Start-Process with "$env:windir\regedit.exe" to import a file that has HKEY_LOCAL_MACHINE\SOFTWARE\TESTING as a key, but it still wrote it under the WOW6432Node. –  Zenox Sep 24 '12 at 16:58
    
I checked this a bit further and confirmed that if I run: Start-Process "$env:windir\regedit.exe" from Power GUI Script Editor (x86) it still launches the 32 version of regedit. –  Zenox Sep 24 '12 at 17:05
    
I was unable to duplicate the issue you describe while using the PowerShell ISE (x86). Perhaps there are other platform considerations that I am unaware of. Tested on W7 x64 and W2K8R2 x64. –  Mitch Sep 24 '12 at 17:32
add comment

Try using reg import under sysnative:

Start-Process $env:windir\sysnative\reg.exe import <.REG_FILE>

$env:windir\sysnative gives you the 64-bit System32 instead of the 32-bit context redirect to SysWOW64.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.