「「ファイル名を指定して実行」からMicrosoft Edgeを起動する」でも書いていますが、UWP(Windows ストア)アプリのAppUserModelId(Application User Model ID)さえ分かれば「shell:AppsFolder」からアプリを実行することができます。
PowerShellやレジストリから調べることもできますが、アプリケーションフォルダから取得することもできます。
今回はアプリケーションフォルダからアプリのAppUserModelIdを取得するVBScriptを紹介します。
Option Explicit
Dim itm
'[.Namespace("shell:::{4234d49b-0245-4df3-b780-3893943456e1}")]でも可
With CreateObject("Shell.Application").Namespace("shell:AppsFolder")
For Each itm In .Items
WScript.Echo itm.Name & ", " & itm.Path
Next
End With
上記の通り非常にシンプルです。
上記コードを少し変えれば、アプリ名を指定してアプリを実行するスクリプトになります。
Option Explicit
Dim id
id = GetAUMID("電卓")
If id <> "" Then
CreateObject("WScript.Shell").Run _
"explorer.exe shell:AppsFolder\" & id
End If
Private Function GetAUMID(ByVal AppName)
Dim itm
Dim ret
ret = ""
With CreateObject("Shell.Application").Namespace("shell:AppsFolder")
For Each itm In .Items
If InStr(itm.Name, AppName) Then
ret = itm.Path
Exit For
End If
Next
End With
GetAUMID = ret
End Function
もちろん、VBAからでも同様のコードでアプリを実行できるので、UWP(Windows ストア)アプリの起動でお困りの方は是非お試しください。




















この記事へのコメントはありません。