Last active
March 22, 2019 15:05
-
-
Save ArtisanByteCrafter/91167d5178a13f7c038236a5d7881ca7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Often, a 32-bit binary needs to call a 64bit binary or registry hive. | |
# Place the following code at the very top of a powershell script to determine if powershell.exe is being invoked as a 32bit process, redirect it to use 64bit, then continue executing whatever follows. | |
# Relaunch in x64 powershell if not already | |
if ($PSHOME -like "*syswow64*") { | |
Write-Output 'Relaunching as x64' | |
& (Join-Path ($PSHOME -replace 'syswow64', 'sysnative') powershell.exe) ` | |
-File $Script:MyInvocation.MyCommand.Path ` | |
@args | |
Exit | |
} | |
# rest of code goes below here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment