Forum > Win32/64

What version of Powershell

(1/5) > >>

dbannon:
Is there some way I can tell the Windows version (ie Vista, 8, 10 etc) at run time ?

Like a define for example ?

I need to be able to determine if Powershell is available and I know thats only Windows 8 and 10.

Davo

winni:
Hi!

Use the values from sysutils:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program EchoWinVersion;uses sysutils; begin  Writeln('Win32 Platform    : ', Win32Platform    );  Writeln('Win32 Major Version: ', Win32MajorVersion);  Writeln('Win32 Minor Version: ', Win32MinorVersion);  Writeln('Win32 Build Number : ', Win32BuildNumber );  Writeln('Win32 CSD Version  : ', Win32CSDVersion  );  readln;end. 
The documentation is at
https://wiki.freepascal.org/WindowsVersion

Winni

440bx:

--- Quote from: dbannon on October 13, 2019, 12:25:03 pm ---I need to be able to determine if Powershell is available and I know thats only Windows 8 and 10.

--- End quote ---
I believe Powershell is also included with Windows 7.  A google search seems to confirm that.

rvk:
Maybe checking the registry for the existence is a better choice...

https://stackoverflow.com/a/1825604/1037511


--- Quote ---To determine if PowerShell is installed, you can check the registry for the existence of

HKEY_LOCAL_MACHINE\Software\Microsoft\PowerShell\1\Install
and

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3
and, if it exists, whether the value is 1 (for installed), as detailed in the blog post Check if PowerShell installed and version.
--- End quote ---

dbannon:
Thanks folks, as always, great help.

I think I will try rvk's approach and test for the existence of powershell itself although I think I recall reading that earlier versions of powershell did not do everything later ones did. My interest is in downloading a file to a specific location, ideally without throwing up a text window to worry the users.

I will experiment ....

Thanks for the great advise every one !

Davo

Navigation

[0] Message Index

[#] Next page

Go to full version