How to Run in Only x86 PowerShell

Computer processor clocks are composed of either a 32-bit or a 64-bit memory register, which is used in executing the computations of the processor. The 32-bit architectures are also known as x86. Software is designed to run on either 32-bit or 64-bit processors. And if you have a PowerShell script that you'd like to run in x86 mode only, you can create a subscript to force your script to comply with your processor's architecture.

Instructions

    • 1

      Double-click on your .ps1 file to open your PowerShell script in Notepad for editing. Notepad should be the default program for handling the script. If Notepad isn't set as the default program, you can open your .ps1 file through Notepad directly -- you can find Notepad in the "Programs" group of the Start menu.

    • 2

      Type the following:

      if ($env:Processor_Architecture -ne "x86")
      { write-warning 'Launching x86 PowerShell'
      &"$env:windir\syswow64\windowspowershell\v1.0\powershell.exe" -noninteractive -noprofile -file $myinvocation.Mycommand.path -executionpolicy bypass

      This sets up the introductory script for launching PowerShell's x86 mode.

    • 3

      Type "exit" and "}" onto the next two lines to specify an end to the script.

    • 4

      Type onto the next three lines of the script:

      "Always running in 32bit PowerShell at this point."
      $env:Processor_Architecture
      [IntPtr]::Size

      This tells PowerShell to run your script in x86 mode only. Close Notepad and save your changes when prompted.

    • 5

      Launch PowerShell from the "All Programs" group of the "Start" menu. Type your script's directory and file name to launch it in x86 mode.

Related Searches:

References

Comments

Related Ads

Featured