Wednesday 15 January 2020

Can't execute msg (and other) Windows commands via subprocess

I have been having some problems with subprocess.call(), subprocess.run(), subprocess.Popen(), os.system(), (and other functions to run command prompt commands) as I can't seem to get the msg command to work.

import subprocess
subprocess.call("msg * Hey",shell=True)

In theory, this should send "Hey" to every computer on the network unfortunately, this isn't running at all and I'm not quite sure why. I can run it on cmd successfully, but can't get it to work from Python.

I'd love to hear why this doesn't work and hopeful a way to fix my code or an alternate solution.

Edit: Solved, thanks for everyone's help. Upgrading to 64-bit Python did the trick.



from Can't execute msg (and other) Windows commands via subprocess

No comments:

Post a Comment