08-29-2025 05:14 AM
@V.Life wrote:
Out of Labview I managed to open and close the prompt window using PowerShell. Can I use the SystemExec block to launch it and execute the same commands that I tried out of Labview? Thanks.
If you would like to kill your application with PowerShell like
Get-Process | Where-Object { $_.Path -like "*MyProgram.exe" } | Stop-Process -Force
then save it as PowerShell script like KillApp.ps1, then call it from LabVIEW like
powershell.exe -ExecutionPolicy Bypass -File "Your\Path\To\KillApp.ps1"
That is:
08-29-2025 05:31 AM
Is it possible also to open the application with PowerShell? Thanks
08-29-2025 06:56 AM
@V.Life wrote:
Is it possible also to open the application with PowerShell? Thanks
Yes, of course, something like that:
Start-Process "<YOUR PATH TO PROGRAM>\MyProgram.exe" -ArgumentList "arg1"
09-01-2025 01:35 AM - edited 09-01-2025 01:53 AM
I managed to execute the script to open the .exe file but it is executed in the black window, not in the window of Power Shell, so I can't close it with the script of closure.
09-01-2025 05:51 AM
@V.Life wrote:
I managed to execute the script to open the .exe file but it is executed in the black window, not in the window of Power Shell, so I can't close it with the script of closure.
Do not confuse the PowerShell window with the console window. If you want to receive output from a console application in PowerShell, you need to run it as follows:
& "C:\Path\To\MyProgram.exe" arg1
09-01-2025 12:58 PM
@V.Life wrote:
I need to close the execution of MyProgram.exe after a fixed time.
Maybe I'm missing something, but when you call the program, can't you pass in an argument (or if the "fixed time" stays the same, build it into MyProgram) so that MyProgram simply stops itself after "a fixed time"?
If the "fixed time" isn't really "fixed", another method that seems less complicated and less reliant on PowerShell or other OS-specific stuff is to have MyProgram look for a "Suicide" file in an easily-accessible Data location, say once/second. If it finds it, it deletes it and then exits. Now all the Master program needs to do is to create the "Go Quit" file in the right location, and MyProgram should stop within a second (as I've written this example).
Note you'd want a different "Quit" routine for each "MyProgram" (and, also obviously, a unique "MyProgram" for each "Master" routine).
Bob Schor
09-01-2025 01:33 PM
@V.Life wrote:
This VI is missing "PostMessage Master.vi".
I provided a link in my previous post, where you can download the library.