Grasshopper-Python: How to start a CMD-Window and send commands to it with options



Hi there.

Within GH via Python code I am trying to open a Command Prompt (Windows 7) and executing some commands in it.
The only thing I manage to do is just to open the CMD window and run a command without options like: “_Run C:/Windows/notepad.exe” or “_Run tasklist”
But any further options to that are ignored. So “_Run tasklist -v” or “_Run echo hello world” doesn’t work.
Can someone point me in the right direction what to do to get this working?
How to run several commands in a row in the same cmd window?

Thanks in advance. (2.8 KB)

(Giulio Piacentino) #2

Hi @Tabak,

Space has a special meaning for the Rhino Command Line interface. You need to use double quotes to make the input exact.

Also, just look up examples of Python shell modules… os.system and

from subprocess import call

file = r"C:\Users\test\"
call(["cmd", "/K", "notepad.exe /A " + file + ""]) 


You may also start programs without the cmd command, this is only an example.



Giulio Piacentino
for Robert McNeel & Associates