import subprocess
subprocess.Popen(['cd/users/Charis Charilaou/desktop/Umbra/Gaming/Minecraft/Minecraft Server/UmbraCraft Test-Server', 'run.bat'] ,shell=True)
Asked
Active
Viewed 291 times
0

IMParasharG
- 1,869
- 1
- 15
- 26

retr0
- 13
- 3
-
2Does this answer your question? [running multiple bash commands with subprocess](https://stackoverflow.com/questions/17742789/running-multiple-bash-commands-with-subprocess) – David Dec 16 '19 at 16:00
-
teh most simple way to do what (i assume) you actually want to do is to have something like `SET mypath=%~dp0` followed by `cd %mypath%` at the top of your `run.bat` file. then you can call it directly and it will change to the right folde start %mypath%\1.4\xiFDR-latest.bat – Lutz Dec 16 '19 at 16:03
-
For the specific use case of running in a particular directory, simply use the `cwd=` keyword argument of the `subprocess` family of functions. – tripleee Dec 16 '19 at 16:07
-
how can I do this? (could you send me the code?) – retr0 Dec 16 '19 at 20:42
1 Answers
0
You can use the chaining symbol &&
for that, for example:
subprocess.Popen(['cd /users/Charis Charilaou/desktop/Umbra/Gaming/Minecraft/Minecraft Server/UmbraCraft Test-Server && bash run.bat'], shell=True)

marcos
- 4,473
- 1
- 10
- 24
-
This would work for a Unix-compatible shell, but it looks like the OP is a Windows victim. – tripleee Dec 16 '19 at 16:04
-
... Or else they are confused; while the `.bat` extension would generally only work on Windows, their home directory looks like a vaguely Unixy one. – tripleee Dec 16 '19 at 16:13