'Using cmd to start TabPy

I am trying to run some cmd commands using a .bat file. This will be ran on a server so we can use python with Tableau server. The .bat file needs to first start the command prompt then navigate to the target folder and run the activate.bat file. This starts my anaconda prompt window. In there, I execute tabpy to start tabpy.

These are the lines verbatim I have in my .bat file.

@ECHO OFF
start cmd
/k cd C:\Users\John Smith\Anaconda3\Scripts
/k activate.bat
/k tabpy
pause

When I run this .bat, a cmd window opens but nothing happens. I'm new to cmd and kind of have no idea what I'm doing. I put this together after reading a couple random sites. Thanks in advance!

Just to clarify, If I go into cmd prompt and type the following in this order, I get what I want:

cd C:\Users\Michael B Smith\Anaconda3\Scripts
activate.bat
tabpy

I just need to duplicate that using a .bat file.



Solution 1:[1]

Assuming tabpy is a python script.

@ECHO OFF
cd /d C:\Users\John Smith\Anaconda3\Scripts
call activate.bat
py.exe tabpy
pause

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Squashman