0

I want to open a WPF application from remote machine using PowerShell. This is the command I'm using

   Invoke-Command -ComputerName "ComputerNamne" -ScriptBlock { & "C:\...App.exe" } -credential "Username"

but for some reason nothing happens

I was able to start the process when calling batch file which calls the applcation

Invoke-Command -ComputerName "ComputerNamne" -ScriptBlock { & "C:\...RubApp.bat" } -credential "Username"

but in this way the GUI is not appearing. I can see in task manager that the app is running though.

So two questions:

  1. Why can't I run directly the exe file?
  2. Why the GUI is hidden in the second method. Can I solve this?
8
  • Here's different ways to start program in powershell: social.technet.microsoft.com/wiki/contents/articles/… . I would use Start-Process (start/saps) Commented Dec 19, 2016 at 15:38
  • 4
    You can't run a graphical app from invoke-command or other WinRM methods. If you want to do that, look into using psexec with the -i switch Commented Dec 19, 2016 at 15:42
  • @maximdumont, you can run graphical apps using this method? Commented Dec 19, 2016 at 15:45
  • Thanks @BenH. I'll look into it Commented Dec 19, 2016 at 15:48
  • 1
    Try adding the console id after -i. If you are trying to display in console session 2, you would use: PsExec \\machine -i 2 -d "C:\..App.exe" Commented Dec 19, 2016 at 18:00

2 Answers 2

1

For invoking GUI app , you have to use PSexec with -i :

You can download it from here and you will get to know how to use also. PSTools Download

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

0

I concur with Ranadip on this one. This is not a feature of powershell, as neither WinRM nor WMI will allow you to utilize a GUI application remotely.

See a similar question: Running remote GUI app in Powershell

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.