Skip to content

Start-Process with AppX application URLs cannot be combined with -PassThru or -Wait #10996

Closed

Description

Note: Perhaps there's no solution, in which case the error message should improved to provide a specific hint.

UWP / AppX-packaged applications (Microsoft Store applications) are launched by URL scheme (e.g., calculator: to start the Calculator app) rather than executable file name.

Combining this style of launching with -PassThru in order to obtain a process object identifying the newly launched process fails; ditto with -Wait to effect synchronous execution.

Steps to reproduce

Run the following on Windows:

{ Start-Process calculator: -PassThru } | Should -Not -Throw
{ Start-Process calculator: -Wait } | Should -Not -Throw

Expected behavior

The tests should pass.

Actual behavior

The tests fail (Calculator still launches, but no process object is returned / waiting doesn't occur, and an error is emitted):

Expected no exception to be thrown, but an exception 
"This command cannot be run completely because the system cannot find all the information required."
was thrown

Environment data

PowerShell Core v7.0.0-preview.5 on Microsoft Windows 10 Pro (64-bit; Version 1903, OS Build: 18362.418)

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Nov 6, 2019
  2. changed the title [-]Start-Process with AppX application URLs cannot be combined with -PassThru[/-] [+]Start-Process with AppX application URLs cannot be combined with -PassThru or -Wait[/+] on Nov 6, 2019
  3. StewartRyanSony commented on Apr 1, 2022

    @StewartRyanSony

    +1. I'm running into this issue as well

    
    Name                           Value
    ----                           -----
    PSVersion                      7.2.2
    PSEdition                      Core
    GitCommitId                    7.2.2
    OS                             Microsoft Windows 10.0.18363
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0```
    
  4. jborean93 commented on May 20, 2022

    @jborean93
    Collaborator

    This came up in the Discord and it looks like pwsh is expected Process.Start to return the Process object that was started but .NET is not doing so. This result bubbles up the stack to this message as there is no process object to passthru or wait on.

    You can verify this behaviour with:

    $psi = [System.Diagnostics.ProcessStartInfo]@{
        FileName = '...'
        UseShellExecute = $true
    }
    $proc = [System.Diagnostics.Process]::Start($psi)
    $null -eq $proc  # $true

    In my example FileName was a jpeg that was associated with a UWP.

    It seems like the problem exists in .NET and needs to be fixed there. I haven't dug into that layer to figure out why it's not returning the process object as it's definitely starting it. Most likely it's the changing executable name.

  5. jborean93 commented on May 20, 2022

    @jborean93
    Collaborator

    Just a further note, it looks like .NET tries its best to get the process handle https://github.com/dotnet/corefx/blob/b8b81a66738bb10ef0790023598396861d92b2c4/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Win32.cs#L90-L116.

    In some cases ShellExecuteEx might have it set to NULL and I think this is one of them. Unless there's a better API or mechanism in Windows/explorer to use it might just be a limitation of these types of apps and PowerShell should just generate a better error message on return if -PassThru or -Wait is being used.

    GitHub
    This repo is used for servicing PR's for .NET Core 2.1 and 3.1. Please visit us at https://github.com/dotnet/runtime - corefx/Process.Win32.cs at b8b81a66738bb10ef0790023598396861d92b2c4 · dot...
  6. guyrleech commented on Dec 14, 2023

    @guyrleech

    I get this error with Windows PowerShell 5.1 on Windows 10 when using start-process on the new Microsoft Teams which is an AppX package although the new process does start. Don't get the error with the same code and Teams version on Windows 11

  7. TheErstwhile commented on Feb 10, 2024

    @TheErstwhile

    I found a sloppy work around for this issue. Not sure if I am allowed to post those here. I tested it with the XBox App.
    Start-Process xbox: then sleep for a few seconds Start-Sleep -Seconds 5. After the sleep get the running process and pipe that into Wait-Process Get-Process xboxPcApp | Wait-Process Script will pause until you close the XBox Window (Note: you need to have XBox App configured to close and not hide in settings).

  8. agajdosi commented on Jan 3, 2025

    @agajdosi

    Did this issue fall through? Better error message could save a ton of time. Travis Plunk (@TravisEz13)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions