# Invoke-CommandInDesktopPackage ( Not able to execute Invoke-CommandInDesktopPackage  with Ansible (win\_shell) option

**URL:** <https://forum.ansible.com/t/invoke-commandindesktoppackage-not-able-to-execute-invoke-commandindesktoppackage-with-ansible-win-shell-option/32556>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [March 30, 2020, 4:13am UTC](https://forum.ansible.com/t/invoke-commandindesktoppackage-not-able-to-execute-invoke-commandindesktoppackage-with-ansible-win-shell-option/32556 "2020-03-30T04:13:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raviteja\_Jinkala](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Raviteja\_Jinkala](https://forum.ansible.com/u/Raviteja_Jinkala)\
**Post date:** [March 30, 2020, 4:13am UTC](https://forum.ansible.com/t/invoke-commandindesktoppackage-not-able-to-execute-invoke-commandindesktoppackage-with-ansible-win-shell-option/32556/1 "2020-03-30T04:13:38Z")

</div>

Hi Team,

I am not able to execute Invoke-CommandInDesktopPackage with Ansible (win\_shell) , facing below error. please check and let me how to fix the issue.  
I am running with Full access User.

Invoke-CommandInDesktopPackage : System.UnauthorizedAccessException occurred when attempting to \r\ninvoke the provided command in desktop package.  
Run Invoke-CommandInDesktopPackage -? for usage \r\ndetails. Additional detail: Access is denied. (Exception from HRESULT: 0x80070005 (E\_ACCESSDENIED))\r\nAt C:\launch.ps1:16 char:6\r\n+ Invoke-CommandInDesktopPackage "cmd" -Args $executable -PackageF …\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (🙂 [Invoke-CommandInDesktopPackage], UnauthorizedAcce \r\n ssException\r\n + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Windows.Appx.PackageCom \r\n mands.InvokeCommandInDesktopPackage\r\n \r\nStop-Process : Cannot stop process "cmd (424)" because of the following error: Windows PowerShell \r\nis in NonInteractive mode. Read and Prompt functionality is not available.\r\nAt C:\launch.ps1:19 char:6\r\n+ Stop-Process -Name CMD\r\n+~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : CloseError: (System.Diagnostics.Process (cmd):Process) [Stop-Process \r\n], ProcessCommandException\r\n + FullyQualifiedErrorId : CouldNotStopProcess,Microsoft.PowerShell.Commands.StopProcessCommand",

---

<div class="post-metadata">

**Author:** ![Raviteja\_Jinkala](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Raviteja\_Jinkala](https://forum.ansible.com/u/Raviteja_Jinkala)\
**Post date:** [March 30, 2020, 4:52am UTC](https://forum.ansible.com/t/invoke-commandindesktoppackage-not-able-to-execute-invoke-commandindesktoppackage-with-ansible-win-shell-option/32556/2 "2020-03-30T04:52:54Z")

</div>

Even windows to windows execution, it is giving below error, does Invoke-CommandInDesktopPackage don’t work through remote execution.

Invoke-CommandInDesktopPackage : A specified logon session does not exist. It may already have been terminated. \r\n(Exception from HRESULT: 0x80070520)\r\nAt line:10 char:1\r\n+ Invoke-CommandInDesktopPackage "cmd" -Args $executable -PackageFamily …\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \r\n + CategoryInfo : NotSpecified: (🙂 [Invoke-CommandInDesktopPackage], COMException\r\n + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.Windows.Appx.PackageCommands.Invok \r\n eCommandInDesktopPackage

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [March 30, 2020, 6:31am UTC](https://forum.ansible.com/t/invoke-commandindesktoppackage-not-able-to-execute-invoke-commandindesktoppackage-with-ansible-win-shell-option/32556/3 "2020-03-30T06:31:12Z")

</div>

Try using Ansible become to workaround this problem. It isn’t a guarantee but it acts like the process was executed on an interactive logon. You could have trouble if the command is expecting user input. This can’t be done on Ansible.
