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++.

Step 1: 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
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?
I like your introduction, it's not often that a person thinks to introduce an Instructable like this.<br /> What are those temp files you're supposed to delete every week or so?<br /> <br /> L<br />
&nbsp;the temp files are in C://Windows/Temp, their ending is .tmp, they're files that programs create for&nbsp;temporary use. &nbsp;Some programs delete their temps themselves when you shut them down, some don't. &nbsp;if you run the Disk cleanup, it should get rid of these also. &nbsp;But they build up over time, taking up disk space, and&nbsp;malicious files sometimes hide there.&nbsp;
&nbsp;Here is where batch comes in!<br /> del *.tmp will get rid of them If only i can do this to cookies...
no... you would delete all .tmp, and thats not the purpose of deleting them. You may would get problems with some programms...<br>Also its just for deleting them in C:/windows/temp (not on all systems, sometimes its hidden in the userfolder ^-^)
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.<br /> <br /> L<br />
&nbsp;no prob
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...<br> <br> <sub><sup><strong>P.S.</strong><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I really want to see your whole page with reasons to use .cmd instead of .bat!</sup></sub>
Also XP. You had to install command.com, but that would be stupid...<br>Windows has not any command.com since win2k...
<strike>but I see you're using Vista...</strike><br> Never mind, I see you're using 7.<br> <br> Also as lemonie said, I love your intro!<br>
nothing for bad, but i use .bat. It works on everything and works nice...<br>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...
i have saved this on a usb flash drive. how do i create a path to my files on it?
<br /> Nice instructions. I&nbsp;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.<br /> <br /> #&nbsp;Script DeleteTemp.txt<br /> var str list, file<br /> lf -r -n &quot;*&quot;&nbsp;&quot;/windows/temp&quot;&nbsp;($fatime &lt;&nbsp;addtime(diff(&quot;-30000000&quot;))) &gt;&nbsp;$list<br /> while ($list &lt;&gt;&nbsp;&quot;&quot;)<br /> do<br /> &nbsp;&nbsp;&nbsp; lex &quot;1&quot;&nbsp;$list &gt;&nbsp;$file<br /> &nbsp;&nbsp;&nbsp; system delete (&quot;\&quot;&quot;+$file+&quot;\&quot;&quot;)<br /> done<br /> <br /> <br /> Feel free to use this script.&nbsp;In case you want to change it, the documentation for lf, addtime, etc. are at <a href="http://www.biterscripting.com/" rel="nofollow">http://www.biterscripting.com</a> .<br /> <br /> <br />

About This Instructable


9 favorites


More by feelsgoodman:
Add instructable to: