Is anyone able to explain how the Windows/Open Actions work?
And also the python console?
I have a powerscript .ps1 file I was wanting to launch from either of these options and it just doesn't seem to work.
If I try to just run the following as a Windows Action.
I get the error message "Unable to run command powershell".
However if I try to run cmd I don't get an error and I know it is doing something in the background because running the following Windows Action launches notepad.
cmd /c ("notepad")
In the python console if I run the following script then notepad happily pops up.
import subprocess subprocess.call(['notepad'])
But if I replace 'notepad' with 'powershell' I get the following error.
Traceback (most recent call last): File "C:\OSGEO4~1\apps\Python36\lib\code.py", line 91, in runcode exec(code, self.locals) File "<input>", line 1, in <module> File "C:\OSGEO4~1\apps\Python36\lib\subprocess.py", line 267, in call with Popen(*popenargs, **kwargs) as p: File "C:\OSGEO4~1\apps\Python36\lib\subprocess.py", line 707, in __init__ restore_signals, start_new_session) File "C:\OSGEO4~1\apps\Python36\lib\subprocess.py", line 990, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified
I expect this has something to do with an OSGEO4 shell that is running in the background or that is called by these commands?
I haven't been able to find detailed information about or good examples of how these functions work outside of doing things within QGIS, where I want to use QGIS to run certain functions outside of QGIS (via powershell scripts), I assume it is possible?
Also if someone does run powershell scripts from within QGIS could you please explain how it is done? And if you feed it variables I'd be very interested in that too (though assuming I can run ps1 scripts I assume the easiest way would be to output the variable into a text file and just have the ps1 script read in the text in there, or output a ps1 file and call it from another ps1 file?