I want my 7-zip self-extracting archive to run a PowerShell script after it extracts files. To do that, I use method described here: http://www.sphaero.org/blog:2011:0504_7zip_self_extracting_autostart_exe

After file extraction I want to run a powershell script, so here is my config.txt file contents:


The InstallCU.bat file launches PowerShell:

powershell.exe -ExecutionPolicy Unrestricted -File InstallCU.ps1

Inside the powershell script I do many things, including checking some registry keys under this branch:


using Test-Path and Get-ItemProperty cmd-lets

I didn't test it out, but I think on 32-bit computers everything will run fine.

My problem is that on 64-bit systems, 32-bit (x86) version of the PowerShell launches. When I access any path in registry under HKLM:\Software in it, it is being redirected to HKLM:\Software\Wow6432Node\ and, of course, fails to find the information I need (because it is in the 64-bit registry branch)


1) How do I make 64-bit 7-zip SFX?


2) How do I run 64-bit PowerShell from 32-bit SFX?


3) How do I read 64-bit registry (not Wow6432Node) via 32-bit powershell? (Though I think that's either impossible or will greatly increase the amount of PowerShell code)


Any other suggestions?

2 Answers 2


Here is a nested Archetype function for determining OS bitness + Powershell bitness. Added sysnative path in a variable to reg.exe so you can reg edit the x64 keys from a 32bit process. If you don't prefer reg.exe, I'm sure there are other ways to do the same trick.

    Function ARCHETYPE (){

    $ARCH = (Get-WmiObject -class Win32_OperatingSystem | Select-Object OSArchitecture).OSArchitecture
    If ($ARCH -eq '64-bit') {
    $DOUBLEARCHES = (Get-Process -Id $PID).StartInfo.EnvironmentVariables["PROCESSOR_ARCHITECTURE"]
    If ($DOUBLEARCHES -eq 'x86') {
    Write-Host 'Running 32-bit PowerShell on 64-bit Windows'
    $REG = "%WINDIR%\sysnative\reg.exe"
    ElseIf ($DOUBLEARCHES -eq 'amd64') {
    Write-Host 'Running 64-bit PowerShell on 64-bit Windows'
    $REG = "%WINDIR%\system32\reg.exe"
    Write-Host 'Running 32-bit PowerShell on 32-bit Windows'
    $REG = "%WINDIR%\system32\reg.exe"
    Write-Host "$REG"



Running 64-bit PowerShell on 64-bit Windows


Running 32-bit PowerShell on 64-bit Windows

Probably to late but it's worth to let anybody else know, there is a module "7zsd_All_x64.sfx" add it to your config file and archive and you will have a 64 bit


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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