3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Advance Batch Files

Advance Batch Files
Ok, lets get some things straight.   1st: batch files ARE NOT PROGRAMS, they are scripts. 2nd:  batch scripts were made to automate window's functions, NOT to make super awesome 1337h4x0r t00ls.  If you want to learn how to make REAL programs, i suggest you learn C++, C#, JAVA, ASM, or Visual Basic.  3rd:  STOP USING THE .bat FILE ENDING!  USE THE .cmd FILE ENDING.  here is why:  .bat uses COMMAND.com, which was made for DOS and Windows 9x.  .cmd uses CMD.exe, which is basically just a new version of COMMAND.com, and was made for Windows 2k - Windows 7.  COMMAND.com is 16-bit, and CMD.exe is 32-bit, do your math.  Also, .cmd has all the features of .bat, and more.  here are some things that .cmd's have that .bat's dont:
1. you can use longer filenames
2. you can use directory stacks (PUSHD/POPD)
3. better use of arithmetic and integers
4. and alot more command that i don't feel like getting into, i can fill a whole page with reasons to use .cmd instead of .bat.
the only drawback is that .cmd's wont run on really old systems.

TL;DR:  NOBODY uses the command.com anymore, get good habits and use cmd.exe

Ohhh, and lastly, stop using notepad, it sucks.  Get a real editor, i use SciTE, it has syntax for a ton of programming languages.  another good editor is notepad++.
 
Remove these adsRemove these ads by Signing Up
 

Step 1Parameters

parameters
 Ok, i am going to assume that you have a basic understanding of batch files.  for this you must know the ECHO and PAUSE commands.  type in your editor:
@echo off
echo the first parameter is %1
echo the second parameter is %2
echo and the third parameter is %3
pause
ok save it as whatever.cmd
i suggest that you make a folder C:\\batch, and save all your batches there, just so they are easier to find.
open up the command prompt, type commands:
CD C://batch (or where ever you saved it)
whatever.cmd a b c
you should get:
the first parameter is a
the second parameter is b
and the third parameter is c
press any button to continue...

and thats all! now, you can type whatever.cmd wut now bitch
and you will get:
the first parameter is wut
the second parameter is now
the second parameter is bitch
press any button to continue...

catch my drift?
« Previous StepDownload PDFView All StepsNext Step »
12 comments
Feb 6, 2010. 12:45 PMlemonie says:
I like your introduction, it's not often that a person thinks to introduce an Instructable like this.
What are those temp files you're supposed to delete every week or so?

L
Feb 13, 2010. 1:33 AMknex_mepalm says:
 Here is where batch comes in!
del *.tmp will get rid of them If only i can do this to cookies...
Dec 6, 2011. 10:20 AMDark-player says:
no... you would delete all .tmp, and thats not the purpose of deleting them. You may would get problems with some programms...
Also its just for deleting them in C:/windows/temp (not on all systems, sometimes its hidden in the userfolder ^-^)
Feb 6, 2010. 1:29 PMlemonie says:
Considering the size of my disks, it's video that hogs my space, but I've still got plenty. I get what these are now, it's nice to be tidy, thanks.

L
Jan 20, 2011. 7:19 PMArbitror says:
I have to protest about the .bat/.cmd differences. In widows 7 and Vista (not sure about XP), both .bat and .cmd files are executed through CMD.exe, and both have the same limitations. Pushd/Popd commands work both with .bat and .cmd. Also, 64bit PCs can not emulate 16bit programs, which is why COMMAND.com is no longer bring used. Your info may be true on XP, as it does use both COMMAND.exe, AUTOEXEC.bat and CMD.exe, but I see you're using Vista...

P.S.
        I really want to see your whole page with reasons to use .cmd instead of .bat!
Dec 6, 2011. 10:16 AMDark-player says:
Also XP. You had to install command.com, but that would be stupid...
Windows has not any command.com since win2k...
Jan 20, 2011. 7:24 PMArbitror says:
but I see you're using Vista...
Never mind, I see you're using 7.

Also as lemonie said, I love your intro!
Dec 6, 2011. 10:14 AMDark-player says:
nothing for bad, but i use .bat. It works on everything and works nice...
I tried to play around with the inegers but it doesn't work better!? I also can use longer filenames and pushd/popd. If you got command.com installed (on win2k and up), that would be stupid. .cmd AND .bat USE THE SAME PROGRAMM: CMD.exe. Thats probably stupid what you are writing...
Oct 30, 2011. 12:24 PMdedric444 says:
i have saved this on a usb flash drive. how do i create a path to my files on it?
Feb 18, 2010. 8:36 AMJenniC says:

Nice instructions. I was looking for something to delete files from /windows/temp that have not been in use for more than 30 days. I ended up writing this script in biterscripting.

# Script DeleteTemp.txt
var str list, file
lf -r -n "*" "/windows/temp" ($fatime < addtime(diff("-30000000"))) > $list
while ($list <> "")
do
    lex "1" $list > $file
    system delete ("\""+$file+"\"")
done


Feel free to use this script. In case you want to change it, the documentation for lf, addtime, etc. are at http://www.biterscripting.com .



Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
0
Followers
1
Author:feelsgoodman