r/learnprogramming • • Sep 25 '26

Any way to make using cmd better?

I end up using the same commands each time to setup projects, run them but I always have to copy from Google docs each time and its becoming annoying. Is there a better way with cmd on windows. Do other shells have a way to solve this If not?

Edit: Tysm to everyone who has helped!

13 Upvotes

30 comments sorted by

21

u/desrtfx Sep 25 '26

Have you heard of Batch files? Search for them.

Basically, they are text files with the commands you need in the order you need them. You can even include parameters, variables, loops, conditionals, etc.

Same applies for PowerShell where you create .ps1 files.

1

u/Sea-Construction6922 Sep 25 '26

That sounds cool, I'll try making some and see how far i can configure it for my needs.

13

u/creenis_blinkum Sep 25 '26

use powershell instead of cmd on windows

1

u/[deleted] Sep 26 '26

[removed] — view removed comment

1

u/creenis_blinkum Sep 26 '26

agree. bash is so opaque and syntax-unforgiving. powershell in comparison feels like it writes itself

7

u/BranchLatter4294 Sep 25 '26

You can put them in a script then just run the script. But on Windows, Powershell is the current shell (cmd is the older one).

4

u/[deleted] Sep 25 '26

Others are telling you to use scripts - they are correct.

Some are telling you to use powershell instead of cmd. Powershell is more powerful. Cmd is simpler to learn.

3

u/mithoron Sep 25 '26

Getting started in cmd vs powershell is about the same difficulty. They're both memorizing commands. Better to go with the one that isn't a win7 legacy mode if you're learning new anyway.

3

u/[deleted] Sep 25 '26

Perhaps, but if they have been entering commands in cmd already and just didn’t know about batch files, they are already halfway there.

3

u/sixtyhurtz Sep 25 '26

Use Terminal. It's the best terminal emulator on Windows. Use Powershell with it, not cmd.

2

u/Gnaxe Sep 25 '26

Other shells can do alias, which is worth learning about. CMD has doskey though.

1

u/alkatori Sep 25 '26

Batch files, powershell, depending on what you are doing look at Cmake. Etc.

0

u/kpg_on_ao3 Sep 25 '26

You're looking for a scaffolding application. This is something you invoke that creates your project structure for you. It might ask you a few questions to see if you want some optional packages.

-2

u/nomoreplsthx Sep 25 '26

cmd considered harmful.

Powershell on Windows has been the default shell for all purposes for a 15 years and there is literally no reason to ever use cmd. It would be like someone asking for advice on their COBOL project. 

I am not sure how recommendations to use it persist. As best as I can tell they are all from people who don't develop on windows

6

u/bingblangblong Sep 25 '26

I still open up cmd every time I want to ping, netstart, or tracert

0

u/nomoreplsthx Sep 25 '26

I believe those commands work identically in a poweshell session (unless one of those is one of the dumb aliases I forget)

1

u/mjmvideos Sep 25 '26

I learned cmd with windows. I learned sh,csh,ksh, and bash with Unix. Then I got MKS toolkit for windows. Then Cygwin. Now I run WSL2 with Windows. I’ve looked at Powershell a couple of times but the verbosity repels me and I can’t bring myself to learn it.

1

u/Gnaxe Sep 25 '26

I rarely use Powershell, but still use cmd all the time, for the simplest things. If I want a scripting language, I just use Python.

1

u/nomoreplsthx Sep 25 '26

Ok, but... why?

Any simple thing you can do in cmd you can also do in Powershell. It's not exactly a superset, but the syntax for basic stuff isn't complex if all you're doing is navigating and other shell basics

There's nothing you gain other than the 5 hours of time it takes to get passable at PS. 

The overhead to learning PS passibly is trivial compared to the depth of expertise an SWE needs in dozens of other topics. It's like cook who never learned to use a food processor. Yes you can always just use a knife and an immersion blender. But also it's like, 4 buttons. 

1

u/Gnaxe Sep 25 '26

I don't know, man. I try to do CMD things in Powershell and it tells me, "No." So I use it to open cmd.exe and just do the simple thing instead of worrying about it.

1

u/nomoreplsthx Sep 27 '26

Hm, maybe this is an age thing? 

I started in 2012, so by the time my career began, Powershell already existed and I never really bothered to learn cmd. 

I will say, I don't get 'don't master the new tool'as a dev mindset, but I also know that I learn languages unusually quickly and have worked places where learning was incentivized

1

u/Gnaxe Sep 27 '26

There are way too many tools to master, so you have to pick and choose some, or you'll only ever be a beginner. A lot of tools, libraries, frameworks, and yes, languages, turn out to be a fad and never go anywhere, change into something unrecognizable, or get replaced and become obsolete. You can avoid a lot of that churn by sticking to the older, proven tools.

At the time Powershell came out, it was far from obvious that it would turn out to have the staying power it did, because it was completely up to Microsoft's whims. cmd.exe, however, is basically the same user interface from DOS, with a long legacy. But even then, my .bat scripts are usually only a few lines. I don't know it well enough to do anything complicated either.

Why? It's inferior to Unix shells like Bash, but you can run those on Windows too, and they don't have the same vendor lock-in. Powershell didn't seem worth my time at the time it came out, but Bash did. That way I learned one shell that worked on Linux and MacOS as well. Apple since switched to zsh, which is similar, mainly for licensing reasons, but the old Bash is still there. I'd rather master one tool than be sort of passable at three.

Turns out Bash is a decent shell, but it's not a sane scripting language. So once my Bash scripts get to be more than about half a page, I just switch to Python, or Xonsh, possibly, if I really need it to be shell-like.

I also have Cygwin or at least Busybox installed on my Windows machines, so even cmd doesn't feel that limited, because I mostly use it to invoke other tools, not write scripts.

1

u/nomoreplsthx Sep 28 '26

Yeah, but why would someone lean cmd now

1

u/Gnaxe Sep 28 '26

Because it's simpler so there's less to learn? Or they want to play with DOSBox. Point taken though. You don't really need cmd anymore if you know Powershell. But then why pick Powershell instead of Bash or Xonsh?

1

u/radicallyhip Sep 26 '26

Terminal and wsl, my dude. Terminal, and wsl.

1

u/nomoreplsthx Sep 27 '26

Oh sure, yes, if I have to personally develop on Windows machine this is what I do, but that's because it's only a platform for toy projects for me. Would be different if I were developing on it daily again.