cm_ExecutePowerShell

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

cm_ExecutePowerShell

Post by *wanderer »

Would such an internal command (cm_ExecutePowerShell) be useful? Perhaps it would be. Recently i have installed MS's new powershell (v7) and it would be nice if there was such a command in TC, which would find the latest version installed on the PC and execute it...

I don't know how easy this would be, if there is perhaps a registry setting pointing to the latest ps version, but IMO it would be useful.
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: cm_ExecutePowerShell

Post by *Horst.Epp »

What is the problem to make a button for users which are interested on Powershell.
If they can't do that it makes no sense to learn or use Powershell :)

Code: Select all

TOTALCMD#BAR#DATA
C:\Program Files\PowerShell\7\pwsh.exe
-NoExit
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
PowerShell in current path

0
-1

Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Re: cm_ExecutePowerShell

Post by *wanderer »

Horst.Epp wrote: 2021-04-29, 15:19 UTCWhat is the problem to make a button for users which are interested on Powershell.
If they can't do that it makes no sense to learn or use Powershell :)
Well, the "problem" would be that in every new version they release, the path will change (C:\Program Files\PowerShell\7, 8, 9, etc...) and if you want the latest version, you will have to change the button every time. On one PC, you will say "oh well, ok, let's do it", but who works on one PC only these days... ;)
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: cm_ExecutePowerShell

Post by *Dalai »

Well, you could still write some script (e.g. Batch, AHK, AutoIt, VBS) that determines the thing you need (the version number) and launches PowerShell afterwards.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Re: cm_ExecutePowerShell

Post by *wanderer »

Dalai wrote: 2021-04-29, 16:29 UTCWell, you could still write some script
Of course, but it would be cleaner if it existed in TC (if there's a straight-forward way).
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Re: cm_ExecutePowerShell

Post by *wanderer »

Hmmm, ok, the usual MS mess...

HKLM\SOFTWARE\Microsoft\PowerShell\1
HKLM\SOFTWARE\Microsoft\PowerShell\3
HKLM\SOFTWARE\Microsoft\PowerShellCore\InstalledVersions\31ab5147-9a97-4452-8443-d9709f0516e1\SemanticVersion = 7.1.3
HKLM\SOFTWARE\Microsoft\PowerShellCore\ProgramsMenuShortcut\7\installed = 1

A different method in each version. Great... :/ Not to mention the different installation paths...
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3854
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Re: cm_ExecutePowerShell

Post by *sqa_wizard »

Just do it the smart way, quick and dirty:

Code: Select all

TOTALCMD#BAR#DATA
powershell

shell32.dll,34
Powershell


-1
#5767 Personal license
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Re: cm_ExecutePowerShell

Post by *wanderer »

sqa_wizard wrote: 2021-04-29, 20:36 UTCJust do it the smart way, quick and dirty
Hmmm... I just tried it and it loaded the newest version. Is it guarantied that it will always do so?

EDIT: The more strange thing is that in the path, powershell 1.0 appears before powershell 7...
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: cm_ExecutePowerShell

Post by *Stefan2 »

wanderer wrote: 2021-04-29, 21:13 UTC ...
. Is it guarantied that it will always do so?
...

Me think yes.


Check your registry for
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\PowerShell.exe

I have (on w10) still the old default since win7
%SystemRoot%\system32\WindowsPowerShell\v1.0\PowerShell.exe


What do you have there?




 
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Re: cm_ExecutePowerShell

Post by *wanderer »

Stefan2 wrote: 2021-04-30, 06:50 UTCWhat do you have there?
%SystemRoot%\system32\WindowsPowerShell\v1.0\PowerShell.exe

(the same). Typing "powershell" in a command prompt executes the old one. Typing the same in search, fetches the new one (first). It doesn't seem consistent...
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
Post Reply