Running a remote EXE, doesn't work

MyHi 21 Reputation points
2021-01-05T12:52:21.623+00:00

I have to run an installer from my system to a remote windows 10 virtual machine.
I tried like this:

$Username = 'user'
$Password = 'pass'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force

$SecureString = $pass

$MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecureString

$vmName = $args[0]

$remote_session = New-PSSession -VMName $vmName -Credential $MySecureCreds
$Directory = "C:\root_file_path"
$cmd = {Start-Process -NoNewWindow -File absolute_path_to_installer -ArgumentList $using:Directory}
Invoke-Command -Session $remote_session -Command $cmd

But the installer doesn't open GUI, on the virtual machine.

I use task manager to see the processes and when I run the command the Powershell process starts and the installer process in the background, but it does not install anything.

My question is: Why the GUI interface doesn't start on my VM?
Thank you!

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,291 Reputation points
    2021-01-05T15:18:19.47+00:00

    Why the GUI interface doesn't start on my VM?

    It's an unattended session. It's running as a background process and is not attached to the desktop user. The easiest solution is to do a silent install. In the -ArgumentList parameters you need to specify the switches to do that.

    Usually the software vendor's documentation will describe how to do that. Sometime you can run "setup.exe /?" or "setup.exe -help" and it will display the command line switches that it accepts. (For whatever the .exe name is.)

    If you really need to interact with the desktop user, then I would suggest using the task scheduler. Define the task to run "AtLogon" and the user account to "INTERACTIVE". Have the task run a .bat file that calls the setup.exe and then deletes the scheduled task so that it doesn't try to run again.

    If you don't want to wait for the user to logon, you can do a schtasks /run (or the Powershell equivalent.)


1 additional answer

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2021-01-05T15:03:50.637+00:00

    You're remoting into a session. It won't appear on the VM. This is basically the same thing that happens when someone remotes into your machine. You won't see them or their UI. This is by design. Each session has its own UI.

    If you're using PS to run an installer then why would you need a UI anyway? That would prevent you from automating it which is what PS is trying to do.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.