0

I am trying to run a python program with an anaconda environment (or just a python with some version) through wscript, which will be placed in a batch file, so I can run the program by just double clicking the batch file.

here is the code

Set WinScriptHost = WScript.CreateObject("WScript.Shell")
WinScript.Run "C:\anaconda3\envs\card_player\python.exe C:\projects\card_player\auto_play.py"
Set WinScriptHost = Nothing

I have no idea why it is not working, meanwhile, run the python is perfectly working by

python c:\projects\card_player\auto_play.py

in the console.

What did I wrong? A console pops up and disappears right away after I click the batch file...

Isaac Sim
  • 539
  • 1
  • 7
  • 23

1 Answers1

0

Replace WinScript.Run "C:\anaconda3\envs\card_player\python.exe C:\projects\card_player\auto_play.py" by the following line:

WinScriptHost.Run("C:\anaconda3\envs\card_player\python.exe C:\projects\card_player\auto_play.py")
Norbert Willhelm
  • 2,579
  • 1
  • 23
  • 33