UWP Apps Identifizieren

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

UWP Apps Identifizieren

Post by BoBo » 29 Nov 2020, 14:06

Hallo Leuts,
basierend auf einer FAQ-Frage in der c't "UWP App per Kommandozeile starten" ergibt sich für mich folgender Prozesssierungsansatz:
a) lokaler download einer Liste von applications mittels Powershell in eine Ausgabedatei
b) parsen der Ausgabedatei nach den Werten der Schlüssel 'PackageFamilyName' und 'InstallLocation'
c) parsen der Datei: '<InstallLocation>\AppxManifest.xml' nach dem Schlüsselwert für '<Application Id='
d) concatinierte Ausgabe aller Treffer mit 'Application Id="App"'

Run,% "powershell.exe Get-AppxPackage | Out-File -FilePath " . A_ScriptDir . "\_appx.txt
Name : Microsoft.Windows.Photos
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 2020.20090.1002.0
PackageFullName : Microsoft.Windows.Photos_2020.20090.1002.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.Windows.Photos_2020.20090.1002.0_x64__8wekyb3d8bbwe
IsFramework : False
PackageFamilyName : Microsoft.Windows.Photos_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
Dependencies : {Microsoft.Photos.MediaEngineDLC_1.0.0.0_x64__8wekyb3d8bbwe,
Microsoft.UI.Xaml.2.3_2.32002.13001.0_x64__8wekyb3d8bbwe,
Microsoft.NET.Native.Framework.2.2_2.2.29512.0_x64__8wekyb3d8bbwe,
Microsoft.NET.Native.Runtime.2.2_2.2.28604.0_x64__8wekyb3d8bbwe...}
IsPartiallyStaged : False
SignatureKind : Store
Status : OK
C:\Program Files\WindowsApps\Microsoft.Windows.Photos_2020.20090.1002.0_x64__8wekyb3d8bbwe\AppxManifest.xml
<Applications>
<Application Id="App" Executable="Microsoft.Photos.exe" EntryPoint="AppStubCS.Windows.App" ResourceGroup="AppGroup">
Ich gehe mal davon aus das sich der jeweilige 'Parsing'-Teil b) & c) mit RegEx fassen lässt?? Nur nicht von mir :crazy: Help!! :shifty:
Nachtrag: c) geht scheints auch mit PowerShell's Get-AppxPackageManifest. JFTR.

Final lässt sich dann eine UWP-app wie folgt starten: Run,% "Explorer shell:appsFolder\Microsoft.Windows.Photos_8wekyb3d8bbwe!App"

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: UWP Apps Identifizieren

Post by BoBo » 30 Nov 2020, 04:41

Jemand ne Idee warum diese Befehlszeile zwar direkt in der PowerShell funktioniert ...

Get-AppxPackage | where-object {$_.IsFramework -eq $false -And $_.SignatureKind -eq "Store"} | Format-List -Property PackageFamilyName,InstallLocation,SignatureKind | Out-File -FilePath C:\_MyPrograms\_Apps.txt

... aber nicht mittels AHK's Run?

F12::Run,% "powershell.exe Get-AppxPackage | where-object {$_.IsFramework -eq $false -And $_.SignatureKind -eq ""Store""} | Format-List -Property PackageFamilyName,InstallLocation,SignatureKind | Out-File -FilePath C:\_MyPrograms\_Apps.txt"

Nö, die geschweiften Klammern zu escapen ` hat auch nichts bewirkt!

Der Inhalt der Ausgabedatei sieht dann anteilig so aus:
PackageFamilyName : Microsoft.Windows.Photos_8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.Windows.Photos_2020.20090.1002.0_x64__8wekyb3d8bbwe
SignatureKind : Store

...
...

just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: UWP Apps Identifizieren

Post by just me » 30 Nov 2020, 05:28

Moin BoBo,

das nutzt recht schlicht Deinen ersten Ansatz:

Code: Select all

#NoEnv
SetWorkingDir, %A_ScriptDir%
SplashTextOn, , , Searching for UWP apps ...
RunWait, powershell.exe Get-AppxPackage | Out-File -FilePath %A_ScriptDir% _appx.txt, , Hide
FileRead, Packages, _appx.txt
AppsList := GetApps(Packages)
SplashTextOff
Gui, Add, ListView, w1000 r25 gRunApp, ID|Family Name|Install Location
For I, V In AppsList
   LV_Add("", V.ID, V.Nam, V.Loc)
LV_MOdifyCol()
Gui, Show, , UW-Apps
Return
GuiClose:
ExitApp

GetApps(ByRef Packages) {
   P := 1
   M := ""
   I := 0
   Apps := []
   While (P := RegExMatch(Packages, "m)^InstallLocation\s+:\s+\K.*$", L, P)) {
      P += StrLen(L)
      If !(P2 := RegExMatch(Packages, "m)^PackageFamilyName\s+:\s+\K.*$", N, P))
         Continue
      P := P2 + StrLen(N)
      FileRead, XML, %L%\AppxManifest.xml
      If !RegExMatch(XML, "im)^\s*<Application Id=""\K[^""]+", ID)
         Continue
      Apps[++I] := {ID: ID, Loc: L, Nam: N}
   }
   Return (I > 0) ? Apps : 0
}

RunApp:
   If (A_GuiEvent = "DoubleClick") && (Row := LV_GetNext()) {
      Gui, +OwnDialogs
      LV_GetText(ID, Row, 1)
      LV_GetText(Nam, Row, 2)
      MsgBox, 0, Run, Explorer shell:appsFolder\%Nam%!%ID%
   }
Return
Das Skript zeigt allerdings alle Packages, die in der Manifestdatei einen Eintrag <Application Id="..." ... haben.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: UWP Apps Identifizieren

Post by BoBo » 30 Nov 2020, 06:03

Moin just me,
merci vielmals für diese Lösung. Allerdings würde mich (inzwischen doch noch) interessieren warum die vorab genannte AHK-Kommandozeile nicht funktioniert!? Idee??

Wer's nachvollziehen möchte: nachfolgend die 'rohen' cmdlets (mit Ausgabe) die manuell in der PowerShell funktionieren ($_.SignatureKind -eq "Store" liefert nur Apps zurück, was das parsen der AppxManifest.xml erübrigen sollte?!).

:)


Get-AppxPackage | where-object {$_.IsFramework -eq $false -And $_.SignatureKind -eq "Store"} | select PackageFamilyName | Out-File -FilePath C:\_MyPrograms\_Apps.txt

/*
PackageFamilyName
-----------------
Microsoft.Windows.Photos_8wekyb3d8bbwe
Microsoft.WindowsCamera_8wekyb3d8bbwe
Microsoft.WindowsCalculator_8wekyb3d8bbwe
Microsoft.WindowsAlarms_8wekyb3d8bbwe
Microsoft.WindowsStore_8wekyb3d8bbwe
*/



Get-AppxPackage | where-object {$_.IsFramework -eq $false -And $_.SignatureKind -eq "Store"} | Format-List -Property PackageFamilyName | Out-File -FilePath C:\_MyPrograms\_Apps.txt

/*
PackageFamilyName : Microsoft.Windows.Photos_8wekyb3d8bbwe

PackageFamilyName : Microsoft.WindowsCamera_8wekyb3d8bbwe

PackageFamilyName : Microsoft.WindowsCalculator_8wekyb3d8bbwe

PackageFamilyName : Microsoft.WindowsAlarms_8wekyb3d8bbwe

PackageFamilyName : Microsoft.WindowsStore_8wekyb3d8bbwe
*/

User avatar
Ragnar
Posts: 611
Joined: 30 Sep 2013, 15:25

Re: UWP Apps Identifizieren

Post by Ragnar » 30 Nov 2020, 06:11

Du musst den Command-Parameter nutzen und die Anführungszeichen für PowerShell selbst auch nochmal "escapen". So klappt's:

Code: Select all

Run % "powershell -Command ""Get-AppxPackage | where-object {$_.IsFramework -eq $false -And $_.SignatureKind -eq \""Store\""} | Format-List -Property PackageFamilyName,InstallLocation,SignatureKind | Out-File -FilePath C:\_MyPrograms\_Apps.txt"""
Last edited by Ragnar on 30 Nov 2020, 06:57, edited 2 times in total.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: UWP Apps Identifizieren

Post by BoBo » 30 Nov 2020, 06:37

Danke Ragnar,
"So klappts" ergab keine Ausgabe!??
"... bessere[s|n] Verständnis" funktionierte. :thumbup:

User avatar
Ragnar
Posts: 611
Joined: 30 Sep 2013, 15:25

Re: UWP Apps Identifizieren

Post by Ragnar » 30 Nov 2020, 06:58

Ja, stimmt, ich habe es nicht ausreichend getestet. Ich habe es geändert.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: UWP Apps Identifizieren

Post by BoBo » 02 Dec 2020, 04:48

Et looft! Doch schon droht die nächste Frage ...

Run,% "Explorer shell:appsFolder\Microsoft.Windows.Photos_8wekyb3d8bbwe!App" startet die Photo-App. Zu finden unter folgendem Pfad im Explorer: "shell:appsFolder".
Dort ist sie (meinen lokalen Einstellungen gemäß) als 'Fotos' benannt. Ähnlich verhält es sich mit der Camera-App = 'Kamera', oder der Calculator-App = 'Rechner'.

Tusch! Wie kann ich aus dem System die aktuell verwendete Bezeichung extrahieren um diese anschließend zuordnen zu können?
In der Registry habe ich mit der Nadel 'Microsoft.Windows.Photos_8wekyb3d8bbwe' nichts gefunden!?
Ich hege den Verdacht das besagter AppsFolder die StartMenü-Einträge spiegelt, evtl lässt sich dort ansetzen??


Post Reply

Return to “Ich brauche Hilfe”