Jump to content

Do .bat files always launch in command prompt?

Jjsimpleton

I have a discord.py bot I run on my laptop. I have a little .bat script (pasted below) to quick boot it up when I'm not working on it from my IDE. It's great because I can just double click the file and it's going.

I would like to utilize the new Window's Terminal (WT) tabs. To run my little script from WT I have to open WT, cd dir AND run the file, which is a minor inconvenience I simply cannot live with.

As the title implies, my script always open in command prompt, which is ugly. I want it to open in WT instead.

 

@echo off
cd C:\GoonBot
venv\Scripts\python.exe main.py

 

Link to comment
Share on other sites

Link to post
Share on other sites

You could probably add the script to the path environment variables so that you just have to type SomeCommandIMade

 

Edit: nvm that wont change the fact that it will open in CMD

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

A batch file, that is .bat or .cmd is exclusive to windows and will only be launched through a command line interface (CLI) which in this case is the command prompt. So no, you cannot really modify a .bat file to launch with something else.

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, AndreiArgeanu said:

A batch file, that is .bat or .cmd is exclusive to windows and will only be launched through a command line interface (CLI) which in this case is the command prompt. So no, you cannot really modify a .bat file to launch with something else.

Microsoft has launched their Windows Terminal application a while ago. Its a tabbed system that allows you to have powershell, WSL and CMD tabs open all in the same application. Last I heard they're working on supporting terminal as a configurable default for all CLI operations.

 

terminal.thumb.png.57d88006f512a9232be8bf76f5ba35bb.png

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

39 minutes ago, trag1c said:

You could probably add the script to the path environment variables so that you just have to type SomeCommandIMade

 

Edit: nvm that wont change the fact that it will open in CMD

I added the path to the path variable, but I don’t know how to activate it from the WT. 

Link to comment
Share on other sites

Link to post
Share on other sites

12 hours ago, Jjsimpleton said:

I added the path to the path variable, but I don’t know how to activate it from the WT. 

I think there is a round-about way of doing it.  Bat files will I think by default open in cmd, but you can still call it from the WT window using a bat

 

e.g.

@echo off
start wt -d "C:\GoonBot" -H "venv\Scripts\python.exe main.py"

Not sure this would work...don't have wt on this computer so can't really try it out.  In theory there should be a way with the wt command line arguments to run the program.

 

Type wt -? and you should see a bunch of stuff...other than that, here is the wt documentation

https://docs.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows

3735928559 - Beware of the dead beef

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×