Corrected incorrect information on step 2 (to do with limitations with parameters).

Added a couple of lines about an auto-installer in step 4.

This instructable will cover the basics of creating your own commands (and even installing them on others computers) which you can use to further cut down the amount of work you need to do.

Some things you should have:
  • A Windows computer (preferably modern)
  • A USB (for transporting the files around)
  • A basic to advanced understanding of the syntax involved with batch commands (this is not a tutorial to help you learn about commands, this is a tutorial about making your own
  • Basic computer know how (for instance, knowing how to navigate through folders)

If you don't have a basic understanding of the syntax involved with batch scripts and the like, feel free to either search for a tutorial, ask questions or comment on something you don't understand.

Step 1: What to Make?

Before you create your world-famous new command, you need to figure out what to make.

Most commands have one specific purpose (such as the REN command), and each switch adds some more functionality to that command. Most of these commands were made because it would be impossible to do a certain task (that batch files are commonly used for) without them. Unfortunately, you cannot make a command that will make something possible that has never been possible before (because if you're making it, it's possible). So, the best thing to base your command around is to save time. 

So, ask yourself, What do I do frequently that takes a long time to program in? 

If you're not that much of the typical "hardcore programmer" (you're using batch here, so not many of you will match that term, it was purely to get my point across), then you might not need a function to save time, because you don't do that much.

In that case, ask yourself something along the lines of Which command lacks something?

That basically means, what command are you not happy with and you think you can do better?

Unfortunately, you can't just modify the code within the commands, so you have to resort to making a new command (such as SETX).

I probably should have explained how the command line (cmd.exe) parses commands. Well, looks like I found my topic for the next section.
<p>Great tut. In your command code, do you need the <em>@setlocal enabledelayedexpansion thing? Or can you change the enabledelayexpansion? It would be great if you answer.</em></p>
Nice tutorial, but your little dice game is weird. It didn't work for me, I had to change &quot;random&quot; to &quot;%random%&quot; but then, I still couldn't figure out the problem
Did you have the other file in the same directory (random.bat)?
<p>Hey, Prof. Pickle, since Cmd.exe uses other files for commands (if u don't get what i'm saying, I am basiclly (spelled wrong) saying the cmds aren't built into command prompt) then wouldn't you be able to find the files it uses and edit them?</p><p>I know they would be invisible but you can make all files in windows visible by tinkering with the folder options&gt;view settings. </p><p>Please reply - Jax B.</p>
<p>Most commands that the command prompt uses are in executable format, written in C++. You can re-write the command, compile it and replace the original, but other than that...</p>
This is very useful for me. Thank you sir. <br> <br>can you tell me how to set help utility for my own command???
I like to put it in sort of an internal &quot;function&quot; which I'd call when they didn't do something right (regarding to arguments). Here's an example: <br> <br>@setlocal &amp; @echo off <br>if %1 equ &quot;&quot; goto :help <br>::code <br> <br>:help <br>echo This is how you use this command...
This I knew. But what about when someone(user) type &quot;Help &quot; ???
If they put it in as an argument (example: command help, command /?) <br> <br>@setlocal &amp; @echo off <br>if &quot;%1&quot; equ &quot;help&quot; goto :help <br>if /i &quot;%1&quot; equ &quot;/?&quot; goto :help <br>::code <br> <br>:help <br>::info
Very nice tutorial! This was very informative! I will be sure to try it.
Glad you liked it. Remember to share what you make!
I haven' made anything yet, I might later on today, right now I am in the middle of starting a text-adventure game. I haven't done batch in so long... I finally recovered my files from my old computer and I saw this tutorial and it got me into batch again. :D
Great tutorial! out of my head..surely I will try it....
Glad you liked it.

About This Instructable




Bio: I enjoy anything to do with computers. I have made some interesting scripts, and I am constantly improving my skill set. One day I hope ... More »
More by Prof. Pickle:How to Create your own Commands with Batch Start a batch file completely hidden Tips on how to find errors in code (focused on DOS) 
Add instructable to: