Currently I am trying to run Stardew Valley from python by doing this:
import subprocess
subprocess.call(['cmd', 'D:\SteamR\steamapps\common\Stardew Valley\Stardew Valley.exe'])
However, this fails and only opens a CMD window. I have a basic understanding of how to launch programs from python, but I do not understand how to specifically open a program that is located not only in a different location, but also on a different drive.
Any help would be appreciated. Thanks!
Edit:
This is on windows 10
Stardew Valley version is the beta and is located on the D:/ drive (windows is on C:/ of course)
Can you try using the steam commandline using the appid of the game:
subprocess.call(r"C:\Program Files (x86)\Steam\Steam.exe -applaunch 413150")
you can find the app id in the "web document tab" from the desktop shortcut properties
(which can be generated by right click and select create desktop shortcut in the steam library).
It will be something like this steam://rungameid/413150
You don't have to use cmd
, you can start the .exe
directly.
Additionally you should be aware that \
is used to escape characters in Python strings, but should not be interpreted specially in Windows paths. Better use raw strings prefixed with r
for Windows paths, which disable such escapes:
import subprocess
subprocess.call([r'D:\SteamR\steamapps\common\Stardew Valley\Stardew Valley.exe'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With