Is it possible to setup a script like this:
file.exe [CMD(POWERSHELL(CMD))]
Here's my code as of now, (combined from answers I've got here):
:RETURN
powershell -command "Start-Process -FilePath '\\my\file\path\myapplication.exe'"
powershell -command "if (gps | ? {$_.mainwindowtitle} | select name, id, mainwindowtitle | where {$_.Name -match 'myapplication'}) { Write-Output 'App verified, running in Taskbar.'} else { Write-Output 'App no running in Taskbar, checking again.' cmd.exe /c 'GOTO RETURN' }"
The above batch file has been converted into a .exe.
My main problem is cmd.exe /c 'GOTO RETURN' is being read as Write-Output instead of a code.
cmdinvocation correct, it still would't work. You cannot make a new, externalcmdprocess execute aGOTO.GOTOonly works inside the context of single batch file being interpreted. It is almost certainly possible to rewrite whatever it is you're doing entirely as a single PowerShell script, but if you're not willing to do that you'll at least have to remain within your originalcmdsession and check the exit code of the PowerShell command, so you can do theGOTOfrom within there as well..batfile instead inside thepowershell -command "..."?powershell -command "..."with multiple lines?