Shayki Abramczyk
Shayki Abramczyk

Reputation: 41545

Why PowerShell opens a new window when running exe

I have a PowerShell script like this:

$tfExe = path/to/tf.exe

& $tfExt ... do something

On my computer (and other PCs) if I run this script I get the .exe output in my PowerShell window.

When I run the script on another computer (with Windows 7 32-bit) it opens a cmd window, the output displayed there, and the window is immediately closed.

The issue occurs for each .exe tool, even in robocopy.

Why does this happen and how can I change it?

Upvotes: 1

Views: 2062

Answers (3)

Vinicius Scheidegger
Vinicius Scheidegger

Reputation: 200

I had a similar issue and figured out I had deleted the folder I was executing the commands from.

PATHEXT was ok: enter image description here

But this was not (I had deleted it outside of PowerShell - oops): enter image description here

Navigating to another path solved the issue.

Upvotes: 1

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41545

I had another issue with my PowerShell and the solution to that issue also solved this issue.

In my PATHEXT environment variable I didn't have .exe. When I added it, the issue solved and all the .exe tools ran smoothly and the output appears in the PowerShell window.

Upvotes: 2

Lars Hedberg
Lars Hedberg

Reputation: 1

You are starting an external exe, so it's working as intended. You could however try using cmd.exe /K - more info here https://ss64.com/nt/cmd.html

Upvotes: 0

Related Questions