2

I would like to automate the start-up process of a Microsoft Windows 10 Universal Windows Platform software application.

According to this question, this issue is still not feasible without resorting to a workaround.

The workaround refers to the writing of a batch file that uses the Microsoft Windows PowerShell integrated shell-scripting environment in order to start that particular software application.

However, there is no straightforward path toward that particular software application within the C:\Windows\SystemApps\ folder.

Any clues?

Update after the comments and the first two answers that have already been provided below:

The app is called as "Weather". Its long name seems to be "Microsoft MSN Bing Weather".

The answer that presents an automated solution based on the Microsoft PowerShell Integrated Shell-Scripting Environment is presented below.

A simple manual work-around is the following one:

  1. Using the Start Menu (and not the Start Screen that covers the whole desktop view as in a full-screen mode), drag-and-drop the "Weather" tile on the desktop view.

  2. Press the Windows+R keys-combination in order to pop up the "Run" dialog box.

  3. Type shell:startup and the Enter key.

  4. Copy the "Weather" shortcut from the desktop view inside the StartUp folder.

  • 1
    what is the `particular software application`? [*grin*] – Lee_Dailey Sep 23 '20 at 13:01
  • Good idea, @Lee_Dailey . Why keep it generic? It is the _Microsoft MSN Weather_ static software application. According to [the File.Net platform](https://www.file.net/process/microsoft.msn.weather.exe.html), its executable binary file should be called as `Microsoft.MSN.Weather.Exe` and stored _"in a subfolder of"_ `C:\Program Files\ ` _"(common is"_ `C:\Program Files\WindowsApps\ ` _"[...])"_. However, somehow I see no `C:\Program Files\WindowsApps\ ` folder on the machines that I am currently accessing. I have searched for the file on the entire `C:\ ` root folders on them. – DOBRESCU_Mihai Sep 23 '20 at 13:39
  • 1
    thank you for the info! [*grin*] it looks like you have two answers to the weirdness of MS store apps. glad to know that things look do-able. – Lee_Dailey Sep 23 '20 at 14:14
  • I totally agree with you, @Lee_Dailey. The UWP's have been a strange addition to the Windows world since their initial design. – DOBRESCU_Mihai Sep 23 '20 at 14:32

2 Answers2

1

You can invoke a UWP Application like this:

explorer.exe shell:appsFolder\<PackageFamilyName>!<PackageName>

If you run the following command in PowerShell:

Get-AppxPackage | Select-Object PackageFamilyName, Name

You'll get the PackageFamilyName and the PackageName returned. which you then can use in the command mentioned above. For example if you want to start the Windows Store:

explorer.exe shell:appsFolder\Microsoft.WindowsStore_8wekyb3d8bbwe!Microsoft.WindowsStore

You could then write your own Start-AppxPackage function (it's a mystery to me why there is no native cmdlet for this yet)

Function Start-AppxPackage {
    
    Param(
        [parameter(ValueFromPipelineByPropertyName)]
        [string]$PackageFamilyName,
        [parameter(ValueFromPipelineByPropertyName)]
        [string]$Name
    )

    Process {
        $Invoke = "explorer.exe shell:appsFolder\{0}!{1}" -f $PackageFamilyName, $Name
        Invoke-Expression $Invoke   
    }
}

and then you can simply use it like this for example:

Get-AppxPackage *photos* | Start-AppxPackage

You can also Start multiple apps at once:

Get-AppxPackage | ? {($_.Name -like '*photos*') -or ($_.Name -like '*store*')} | Start-AppxPackage

This command can then be included in a startup script or something similar

However, to be honest, this seems to be super buggy this starting shell apps via explorer. after a while it only opened the explorer on my documents instead of starting the correct shell app.

SimonS
  • 8,924
  • 5
  • 28
  • 48
  • For the moment, the `explorer.exe shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe` command starts the Documents library. I have to dig further into your answer. "_Simply_" seems to be a misnomer here. – DOBRESCU_Mihai Sep 23 '20 at 14:41
  • As advised by @user19702, the correct PowerShell command should have been the following one: `explorer.exe shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe!Microsoft.BingWeather`, @SimonS. _Still_, it is producing the same Documents library folder instead of starting up the app. – DOBRESCU_Mihai Sep 25 '20 at 10:12
  • 1
    @MihaiDobrescu This is the exact same as I wrote. you just need to find out the PackageFamilyName, the PackageName and put that into the command – SimonS Sep 25 '20 at 10:16
  • I had the impression that `PackageFamilyName` is `Microsoft.BingWeather_8wekyb3d8bbwe` and that `PackageName` is `Microsoft.BingWeather`, @SimonS. If they are both correct, then the `explorer.exe shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe!Microsoft.BingWeather` command is also correct. However, it is _still_ producing the _Documents_ library folder window instead of starting up the app. – DOBRESCU_Mihai Sep 25 '20 at 11:26
  • Also, in the sentence "_after a while it only opened the explorer on my documents instead of starting the correct shell app._", the part "_after a while_" is not true in my case, @SimonS. The `explorer.exe shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe!Microsoft.BingWeather` PowerShell command has _always_ started the "_File Explorer_" app on my machine. – DOBRESCU_Mihai Sep 25 '20 at 13:31
  • My mistake, @SimonS. The correct PowerShell one-liner is actually `explorer.exe shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe!App`, as pointed out by @user19702, and not `explorer.exe shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe!Microsoft.BingWeather`, as it appears in my previous comment to you. So your answer is actually as good as his. I have to thank you, as well, for providing this automation solution for this question to me. Cheers! – DOBRESCU_Mihai Oct 05 '20 at 12:44
1

Windows store apps have a few quirks, but can be dealt with. Powershell refers to windows store apps as AppxPackages, but a package can have more than one app inside it, so we also need to check the AppxManifest.xml file to get more information.

First you'll need the package name, you can find it by dragging a shortcut to your desktop, then checking the properties > Targettype (you only need enough to have a unique name):

TargetType screenshot

In Powershell now, we get the package - you can find the package name by dragging a shortcut to your desktop, then checking the properties > Targettype:

$pkg = Get-AppxPackage *Communication*

Then we get the XML data of its manifest:

$manifest = [xml](get-content "$($pkg.InstallLocation)/AppxManifest.xml")

Then we get the package ID from within the XML:

$ID = $manifest.Package.Applications.Application.id

For our sanity, we check to make sure we only have one app ID:

if ($id.count -gt 1) {Write-Error "Found more than one app ID in package!: $id";break}

In my case, I have more than one, so I'll specify the ID manually:

$ID = 'microsoft.windowslive.calendar'

And finally, we launch the app:

Start-Process explorer.exe -ArgumentList "shell:appsfolder\$($pkg.PackageFamilyName)!$id"

Or as a single script:

$pkg = get-appxpackage *Calculator*
$manifest = [xml](get-content "$($pkg.InstallLocation)/AppxManifest.xml")
$id = $manifest.Package.Applications.Application.id
if ($id.count -gt 1) {Write-Error "Found more than one app ID in package!: $id";break}
Start-Process explorer.exe -ArgumentList "shell:appsfolder\$($pkg.PackageFamilyName)!$id"

Please Note: this has to run as the current logged-in user.

Cpt.Whale
  • 4,501
  • 2
  • 13
  • 25
  • Can you believe it, @user19702? I was so stuck with using the Start Screen in the full screen mode, that I simply could not think about making a shortcut of a Metro tile of a Microsoft Windows 10 Universal Windows Platform static software application on the desktop view. Now I am back to the regular Start Menu. I have nicely created the shortcut. I wonder why the `$pkg = Get-AppxPackage *BingWeather*` PowerShell command does not output anything. – DOBRESCU_Mihai Sep 23 '20 at 14:30
  • Strange. I have tested the `$pkg = Get-AppxPackage *BingWeather*` PowerShell command on two other machines and it _still_ does not return anything. Maybe it is a special app or it has been renamed recently. Who knows? – DOBRESCU_Mihai Sep 24 '20 at 07:08
  • Can you believe it again, @user19702? I was so fixed upon the usage of batch files, of shell-scripts and generally of automation tools, that I could not see the fact that I could _simply_ copy the shortcut from the desktop view inside the `shell:startup` folder. It was _that_ simple. – DOBRESCU_Mihai Sep 24 '20 at 07:24
  • 1
    @MihaiDobrescu The command doesn't return anything because it's writing the output to the `$pkg` variable. Also, the command you have in the comment on the other answer was only missing the `!` and the Package Name. It sounds like you got what you needed though. – Cpt.Whale Sep 24 '20 at 15:16
  • What was I thinking, @user19702? God only knows. Of course that `$pkg = Get-AppxPackage *BingWeather*` is only an assignment PowerShell command. If you mean that the other comment should have contained the `explorer.exe shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe!Microsoft.BingWeather` command, then unfortunately it is _still_ producing the Documents library folder. – DOBRESCU_Mihai Sep 25 '20 at 09:18
  • Also, @user19702, I have tested the 5 Source Lines of Code that you have named "_as a single script_" and they are nicely both starting either the "_Calculator_" or the "_Weather_" apps, if I swap the "`*Calculator*`" with the "`*BingWeather*`" character strings. If you include in your answer an MS-DOS/Microsoft Windows 10 Batch Commands Processing File ("`*.BAT`") that starts the PowerShell script, then I shall award this answer to you. I am too overwhelmed right now and apparently I am making very little and stupid mistakes. Thanks a lot for your efforts. – DOBRESCU_Mihai Sep 25 '20 at 09:50
  • Apparently, @user19702, the `Start-Process explorer.exe -ArgumentList` version of the PowerShell command does the trick, instead of the plain `explorer.exe`-based version. I bet that this is the best answer, once it becomes refined a little bit. Cheers for your good intuition. – DOBRESCU_Mihai Sep 25 '20 at 13:35
  • Nope, I was wrong, @user19702. With your 5 Source Lines of Code, I can nicely produce the pop-up of either the "_Calculator_" app or of the "_Weather_" app. However, why does the `Start-Process explorer.exe -ArgumentList "shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe!Microsoft.BingWeather"` PowerShell one-liner produce the _Documents_ library folder window? It _simply_ deludes me. – DOBRESCU_Mihai Sep 25 '20 at 13:46
  • 1
    @MihaiDobrescu I think you've misunderstood what comes after the `!`, the `$id` for bing weather is simply `app`. For me, this means I can create a desktop shortcut (instead of a batch file) and set the Path to the below, it starts BingWeather: `powershell.exe -c Start-Process explorer.exe -ArgumentList "shell:appsfolder\Microsoft.BingWeather_8wekyb3d8bbwe!App"` – Cpt.Whale Sep 26 '20 at 17:30
  • It has not been a matter of misunderstanding, @user19702. It has rather been an issue of insufficient debugging. With `$pkg = get-appxpackage *Weather*;Write-Output $pkg.PackageFamilyName`, I can clearly see that the `$pkg.PackageFamilyName` is `Microsoft.BingWeather_8wekyb3d8bbwe`. With `$manifest = [xml](get-content "$($pkg.InstallLocation)/AppxManifest.xml");$id = manifest.Package.Applications.Application.id;Write-Output $id`, I can clearly see that the `$id` is `App`. – DOBRESCU_Mihai Sep 28 '20 at 06:57
  • I have just tested and, indeed, from within the _Run_ dialog box, the `powershell.exe -c Start-Process explorer.exe -ArgumentList "shell:appsfolder\Microsoft.BingWeather_8wekyb3d8bbwe!App"` command starts the _Weather_ app. Now I can see that the already-created desktop shortcut to the _Weather_ app already contains as its `Target:` field the `Microsoft.BingWeather_8wekyb3d8bbwe!App` character string. It makes little sense to create another shortcut using a PowerShell call. – DOBRESCU_Mihai Sep 28 '20 at 06:58