I am trying to create an executable (.exe) at windows that will perform some actions at first, and then open an interactive shell. In my case the interactive shell I want to be a wsl, but the problem is shown with every type of shells created. For example:
Supposing that we have the file
test.ps1
Write-Host "Hello from my test program"
Invoke-Expression "powershell"
If I run it with the command: ./test.ps1
, the outcome will be to print the message and start a new powershell instance.
If i run the command: Invoke-ps2exe .\test.ps1 test.exe
, and then run the test.exe
, the outcome will be:
Hello from my test program
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
but I cannot write anything at the window. Can anyone explain me why this is happening, and how I could overcome this?