I have some PowerShell scripts that I need to call from LabVIEW, but I’m having trouble getting them to fully work. The scripts perform automation tasks using the user32.dll. Everything works properly when I run the scripts from PowerShell, PowerShell ISE, command prompt, and the Run command, but the scripts do not fully work when calling them from System Exec.vi. I have LabVIEW 17.0.1 32-bit on Windows 10 Enterprise 64-bit.
When I run the script from command prompt, the command is
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file “path to file.ps1”
That works fine, so in System Exec.vi I set the command line input to
cmd /k
and the standard input to
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file “path to file.ps1”
A command prompt window opens, and the script starts but does not fully work. The script calls a C# function to do a PostMessage simulating a keystroke. There are more PostMessages, but only the first one goes and then nothing after that. There are no error codes associated since the script finishes, but it doesn't fully work.
When I run the script with the Run command, the command is
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file “path to file.ps1”
That also works fine, so in System Exec.vi I set the command line input to
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file “path to file.ps1”
with no standard input. A PowerShell window opens, and script starts but again does not work.
I know the PowerShell and C# side of this is not supported here, but since everything works except for in LabVIEW, does anybody have an idea of why the scripts won’t complete? Would it have anything to do with LabVIEW being 32-bit on a 64-bit computer? Thank you for any input!