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?
Running “regedit “filename” to import .reg file from powershell
64-bitwindows-registrywindows-server-2008
Related Topic
- Powershell – How to Export a Registry HIVE (NTUSER.DAT) in PowerShell
- How to run x64 bit version of registry from cmd.exe located under c:\windows\sysWow64
- Powershell – How to change owner of a Registry Key to which I don’t have access
- Variable path in *.reg file
- Microsoft Intune – How to modify Windows 10 registry settings
- Windows – Read Local “HKEY_CURRENT_USER” from another user, windows batch/powershell
Best Answer
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:
This will open the 64 bit version when on x64, or the 32 bit version when running on a 32 bit machine:
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-bitSystem32
instead of the redirect toSysWOW64
.