Jump to content

Recommended Posts

Posted (edited)

PowerShell 7 on Windows Vista Extended Kernel done properly

So here's how to install 64-bit PowerShell 7 on Windows Vista with Extended Kernel. You MUST use EXACLY version 7.2.2. If you want to know why is that, go to the section why 7.2.2?, but for now here's a

 

Quick step-by-step guide:

 

1. Install Windows Vista Extended Kernel October 2022 x64 version if you haven't already  (only x64 files are needed, less stable x86 ones not required) https://msfn.org/board/topic/183046-guide-vista-extended-kernel-installation/

2. Download zipped version of PowerShell 7.2.2 (PowerShell-7.2.2-win-x64.zip) from GitHub https://github.com/PowerShell/PowerShell/releases/tag/v7.2.2

3. Extract it somewhere, from now on this somewhere is assumed to be "C:\Program Files\PowerShell\7\" so that the path to the main executable is "C:\Program Files\PowerShell\7\pwsh.exe"

4. Add this to your osver.ini in C:\Windows (if it's not there create it)

[C:\Program Files\PowerShell\7\pwsh.exe]
Enabled=1
MinorVersion=1

5. Add "C:\Program Files\PowerShell\7" without quotes to your system Path. To do that go to ControlPanel -> System and Maintenance -> System -> System Properties -> Advanced (it's a tab) -> Environmental Variables. Look for the Path variable and add the aforementioned path to other things after a semicolon ( ; ), thats how things are separated there.

6. Download and unzip this special shortcut https://forum.legacydev.org/viewtopic.php?f=27&t=231 and put it in "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell" so that it appears in the start menu next to the old-school WindowsPowerShell. You can also put it in "%appdata%\Microsoft\Internet Explorer\Quick Launch" to add it to quick launch.

The 2 things that are special about the shortcut I've made are:

  • It launches cmd to launch PowerShell, which is a workaround to a problem with 7.2.2 more in why 7.2.2?
  • It behaves like a WindowsPowerShell window, so it has a range select feature and the iconic PowerShell blue color.

7. Enjoy

file.php?id=247

Why 7.2.2?

So you could just install 7.2.17, 7.2.24 or any other newer 7.2.x version, and it would work fine... mostly

But sometimes those versions hang on startup and never launch staying in a non-functional state which even takes a few seconds when you decide close it. On some machines like 9/10 launch tries are successful on some almost none.

There are even reports of this occurring on Windows 10:

https://old.reddit.com/r/PowerShell/comments/v6arrr/powershell_72x_almost_always_hangs_when_launched/?rdt=40615

https://github.com/PowerShell/PowerShell/issues/17558

But I've managed to reproduce this issue only on Windows Vista machines and multiple ones.

7.2.3 and newer as well as newer 7.1.x like 7.1.7 are affected by this issue on Vista

 

7.2.1 and older as well as older 7.1 and 7.0 on the other hand just fail to launch at all showing a Failed to initialize properly ... smth error.

 

So if it wasn't for 7.2.2 you would have to go back to PowerShell 6 to get a working version

 

But 7.2.2 has it's own issue where it sometimes immediately closes after launching an exe.

Fortunately it doesn't do this when launched from another command line tool, that's why it was necessary to make a shortcut that launches cmd first and pwsh next

Edited by TSNH

Posted

As a bonus here are Vista-compatible .reg files that add PowerShell 7 to the context menus

To use them copy, save a .reg and apply

Open PowerShell here:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\openpwsh]
"MUIVerb"="&Open PowerShell"
"Icon"="C:\\Program Files\\PowerShell\\7\\pwsh.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\openpwsh\command]
@="cmd.exe /k pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\""

 

Open a folder in PowerShell:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\PowerShell7x64]
"MUIVerb"="&Open in PowerShell"
"Icon"="C:\\Program Files\\PowerShell\\7\\pwsh.exe"

[HKEY_CLASSES_ROOT\Directory\shell\PowerShell7x64\command]
@="cmd.exe /k pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\" || pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory \"%V!\" -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'\""

 

Run .ps1 file in PowerShell:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\PowerShell7x64]
"Icon"="C:\\Program Files\\PowerShell\\7\\pwsh.exe"
"MUIVerb"="Run with PowerShell 7"

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\PowerShell7x64\Command]
@="cmd /k pwsh.exe -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\" || pwsh.exe -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\" || pwsh.exe -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\" || pwsh.exe -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\" || pwsh.exe -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\" || pwsh.exe -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""

 

As you can see they try to retry the PowerShell launch if it fails to overcome 7.2.2's bug, and are also in a bit different format than those supplied with PowerShell installer because those didn't work with Vista.

I still haven't figured out how to make run as administrator versions

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...