# Launching applications remotely with GUI

**URL:** <https://forum.ansible.com/t/launching-applications-remotely-with-gui/31366>\
**Category:** Ansible Project\
**Tags:** windows, ansible-project\
**Created:** [September 26, 2019, 11:38am UTC](https://forum.ansible.com/t/launching-applications-remotely-with-gui/31366 "2019-09-26T11:38:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harini\_K](https://avatars.discourse-cdn.com/v4/letter/h/73ab20/32.png) [@Harini\_K](https://forum.ansible.com/u/Harini_K)\
**Post date:** [September 26, 2019, 11:38am UTC](https://forum.ansible.com/t/launching-applications-remotely-with-gui/31366/1 "2019-09-26T11:38:33Z")

</div>

Reference to old post with the same problem :

[https://grokbase.com/p/gg/ansible-project/16442gt7pz/launching-applications-remotely-with-gui](https://grokbase.com/p/gg/ansible-project/16442gt7pz/launching-applications-remotely-with-gui)

I tried with the below options of launching application in GUI mode both through Power shell and Ansible (win\_shell)

**Option #1:**

Enter-PSSession -ComputerName -Credential $cred  
Start-Process ‘C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Snipping Tool.lnk’

**Option #2:**

Invoke-Command -Computername xxxx -ScriptBlock { start-process ‘C:\Windows\System32\notepad.exe’ }

**Option #3:**

psexec.exe \XXXX “C:\Windows\system32\notepad.exe”

All the above specified commands run as **Background service** and **not in GUI Mode**.

Appreciate suggestions for the same

---

<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:** [September 26, 2019, 9:21pm UTC](https://forum.ansible.com/t/launching-applications-remotely-with-gui/31366/2 "2019-09-26T21:21:42Z")

</div>

The same comments in that linked post still pretty much applies here. There is never a guarantee that there will always be an interactive session that has a logged on user so whatever you write will be quite brittle unless you have some pretty in depth checks to conditionally run this beforehand. Ultimately you have to solutions;

- Use PSExec with the ‘-s -i “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Snipping Tool.lnk”’ argument

- The value you set for -i is the dynamic session id for the session you want to display this in, you need to get this somehow

- This is also a security issue as the user will now see a Window that is run with SYSTEM privileges, this means a limited process will now have a way to run things under an admin scope (very dangerous)

- Create a scheduled task that is set to run when the user is logged in and trigger it either immediate or on the next logon.

The scheduled task is your best bet and you can use win\_scheduled\_task to do this like;

`

- name: create task that runs under a user’s interactive desktop  
win\_scheduled\_task:  
name: Interactive Process  
actions:
- path: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Snipping Tool.lnk  
triggers:
- type: repetition  
logon\_type: interactive\_token  
username: actual\_user

`

When that task runs it runs in the context of that particular user.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![Harini\_K](https://avatars.discourse-cdn.com/v4/letter/h/73ab20/32.png) [@Harini\_K](https://forum.ansible.com/u/Harini_K)\
**Post date:** [September 27, 2019, 9:29am UTC](https://forum.ansible.com/t/launching-applications-remotely-with-gui/31366/3 "2019-09-27T09:29:53Z")

</div>

Many Thanks Jordan, that was really helpful.

It worked.

---

<div class="post-metadata">

**Author:** ![Harini\_K](https://avatars.discourse-cdn.com/v4/letter/h/73ab20/32.png) [@Harini\_K](https://forum.ansible.com/u/Harini_K)\
**Post date:** [October 1, 2019, 12:18pm UTC](https://forum.ansible.com/t/launching-applications-remotely-with-gui/31366/4 "2019-10-01T12:18:58Z")

</div>

Hey Jordan,

As per your suggestion , we are able to launch Application in GUI Mode for interactive session (When user is logged in).

Using “logon\_type: S4U” , we are able to launch Application as a Background service, when “user is not logged on”.

Our requirement is to launch an application and take screenshot when “user is logged on or not” (preferably in logged out state).

 ![launch.png](https://us1.discourse-cdn.com/ansible/original/2X/3/34b76e872c069a10f2049851776c40e70a4992eb.jpeg)

Attached the screenshot of our requirement:
