Forum > Win32/64

What version of Powershell

<< < (2/5) > >>

ASBzone:

--- Quote from: winni on October 13, 2019, 01:35:13 pm ---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

--- End quote ---


Except that doesn't give the best Windows version info.


On my Windows 10 system, for example, it returns:



Win32 Platform    : 2
Win32 Major Version: 6
Win32 Minor Version: 2
Win32 Build Number : 9200
Win32 CSD Version  :


ASBzone:

--- Quote from: dbannon on October 14, 2019, 01:18:04 am ---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

--- End quote ---


For powershell version, consider the following:

https://social.technet.microsoft.com/Forums/en-US/7125f618-0c59-45a0-a954-5fd50dd1cc0c/build-numbers-for-powershellexe-vs-powershell-version?forum=winserverpowershell

dbannon:
OK, only have access to two windows platforms, Windows 10 on her ladyship's pc and an arcane Vista on a discarded laptop of mine. Honestly, I believe anyone using Vista has more problems than getting buggy software from me.

 I have done something like this -


--- 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";}};} ---{$ifdef WINDOWS}function TForm1.WeHavePowershell(const Version : char) : boolean;var    Registry : TRegistry;begin    Registry := TRegistry.Create;    try      Registry.RootKey := HKEY_LOCAL_MACHINE;      if Registry.OpenKeyReadOnly('\Software\Microsoft\PowerShell\' + Version ) then           exit(Registry.ReadInteger('Install') = 1)      else            exit(false);    finally      Registry.Free;    end;end;{$endif}
Windows 10 says it has both Powershell 1 and Powershell 3. I expect later versions of Windows will also claim to have 3. I  have found that even Vista has Powershell but its version 1.  I have not been able to obtain a list of functionality but it does seem that syntax has changed. My powershell download code fails but I don't think Vista is worth the effort really of working out why. So, in my case I will say -


--- 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";}};} ---if WeHavePowershell('3') then      DoSomething();else TellUserBadLuck();
I guess if the later Powershell (ie Power Core ??) becomes widespread, I may need to set an option to it to emulate version 3, thats easy.

Thanks for your help folks.

(I'll change the title of this thread to reflect what it became and what I should have entitled it at the start.)

Davo


 

Thaddy:

--- Quote from: 440bx on October 13, 2019, 03:55:05 pm ---
--- 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.

--- End quote ---
Powershell can be installed on any windows version above and including XP, if you want. It is also cross-platform (I am running Powershell on a Raspberry Pi combined with Mono on Raspbian Buster)
See https://github.com/powershell/powershell Microsoft put it in the public domain with its own open source license.

rvk:

--- Quote from: dbannon on October 14, 2019, 01:18:04 am ---My interest is in downloading a file to a specific location, ideally without throwing up a text window to worry the users.

--- End quote ---
Wait... You want to use Powershell to download something?
Why not download it directly in FPC?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version