0

I am looking for a way to run a python script from anywhere.

I have seen this solution but as it is based on Linux I am looking for a way on Windows (10).

Basically what I want to do is, execute a script with a given parameter. Because it could be disturbing for the user, I am using a .pyw-file extension to hide the console.

Things that came to my mind:

  • a PATH-Variable
  • PowerShell-Script
  • Batch-file

Sadly I am not familiar/experienced with neither of those, so I can't really tell if these ideas even provide a way to do that.

Any answer is appreciated.

Edit: I would like to make the command as short as possible for the client so it is not necessary to write a novel to exec one simple task.

Another Edit: I want the user/client to open its cmd/ps and use a command which executes my python-script, which is not in this directory he is, when opening the cmd. So the script is somewhere on his computer, but shall be executable by command from anywhere.

Michael Holley
  • 119
  • 1
  • 12

1 Answers1

1

try to create a "code.bat" file with this command "python script.py" inside your .bat file then add the "code.bat" to your path in your environments anytime you want to run the script just type code in your shell.

Cyberhero
  • 32
  • 6
  • I have tested it with a simple TowersOfHanoi Script and it worked as expected :) I still need to figure out how to use a parameter in addition to that but thanks. You helped me a lot – Michael Holley Feb 19 '20 at 10:45