BEST BATCH TUTORIAL


SUBMITTED BY: Guest

DATE: May 18, 2013, 4:55 a.m.

FORMAT: Text only

SIZE: 8.9 kB

HITS: 998

  1. Ok,eraser , Crow , Codine made batch tuts and no1 understood,because it was complicated..so ill try to make simple as it can be
  2. the words in ( ) are just remarks.. they wont appear
  3. to start off there is the @echo off/on
  4. and there is echo
  5. and pause
  6. so here is an example
  7. Quote:
  8. @echo off
  9. echo Hello This is a test
  10. pause
  11. type this in notepad and save as test.bat
  12. launch it
  13. it will look like this
  14. Quote:
  15. Hello This is a test
  16. Press any key to continue...
  17. Again open notepad and write:
  18. Quote:
  19. @echo on
  20. echo Hello This is a test
  21. pause
  22. and save it on the desktop as test2.bat
  23. launch it , it will look like this
  24. >
  25. Quote:
  26. C:\Documents and Settings\User\Desktop>echo Hello This is a test
  27. Hello This is a test
  28. C:\Documents and Settings\User\Desktop>pause
  29. Press any key to continue
  30. So for the explanation
  31. @echo off/on:
  32. if you put @echo on it will show the directory as you just saw
  33. if you put @echo off it will just show the words with no directories
  34. so its best to use @echo off
  35. echo:
  36. If you want to type a simple phrase just type in echo and something in this case echo Hello This is a test
  37. which will show Hello This is a test
  38. pause
  39. pause will pause the batch file,if you press a key the batch will continue in this case it will exit because there is no more left
  40. so try this
  41. Quote:
  42. @echo off
  43. echo Hello This is a test
  44. pause
  45. echo I am testing pause
  46. pause
  47. This will show
  48. Quote:
  49. Hello This is a test
  50. Press Any Key To Continue...
  51. (when you press a key it will show)
  52. I am testing a pause
  53. Press Any key to continue..
  54. so that convers the pause command
  55. Now some more commands
  56. there is msg *
  57. and there is cls
  58. open notepad and write:
  59. Quote:
  60. @echo off
  61. echo Hello This is a test
  62. pause
  63. cls
  64. echo I am testing pause
  65. msg * The End
  66. pause
  67. and save as test3.bat
  68. This will show
  69. Quote:
  70. Hello This is a test
  71. Press Any Key To Continue...
  72. (when you press a key it will show)
  73. cls
  74. (the page will clear)
  75. I am testing a pause
  76. (a pop-up will show saying The End)
  77. Press Any key to continue..
  78. So .. cls will just clear the screen
  79. and msg * will bring up a pop-up:D
  80. other commands are REM and goto and start
  81. so create a folder name it Test
  82. put any picture inside and name it testpic
  83. open notepad and type
  84. Quote:
  85. @echo off
  86. echo Testing start and rem
  87. rem title Test
  88. start testpic.jpg (or any other extension)
  89. pause
  90. and save it inside the new folder as test4.bat
  91. launch it , it will show:
  92. Quote:
  93. Testing start and rem
  94. Press Any Key To Continue
  95. (and the picture will launch)
  96. so start will launch any file
  97. and rem is a remark.. which wont show in the bat file when running
  98. now the goto and set and if
  99. type this inside notepad
  100. Quote:
  101. @echo off
  102. echo This is a test
  103. echo If you want to do math type 1 and press enter
  104. echo If you want to see a picture type 2 and press enter
  105. set /p option=
  106. if '%option%'=='1' goto :math
  107. if '%option%'=='2' start testpic.jpg (or any extension)
  108. :math
  109. echo 2+2
  110. pause
  111. and save it inside the new folder
  112. this will show
  113. Quote:
  114. This is a test
  115. If you want to do math type 1 and press enter
  116. if you want to see a picture type 2 and press enter
  117. (here you can type 1 or 2 and press enter)
  118. (if you press 2 and Enter the picture will load)
  119. (if you press 1 and enter this will show up):
  120. 2+2
  121. Press any key to continue...
  122. so goto will go to a Label or a Part of the file
  123. when you put :Math
  124. a new label will be named Math and when you put goto :math
  125. the batch will go to :math
  126. set
  127. the set option will set something :D.. here its going to set :choice
  128. the set is , in some options followed by if
  129. so if I type 1 in this example
  130. the "choice" will be 1 .. and it will go to :math because we put
  131. if '%choice%'=='1' goto :math
  132. so if we put 1 the choice will be 1 therefore it will goto :math
  133. anyway those are the basics..
  134. stay on hackforums.net and wait for more batch tutorials.. next time it will be more advanced
  135. Helloo!!!....First go read my batches for n00bs tutorial.. it got the basics.. anyway.. let me start
  136. i am going to talk about call,exit,and SHIFT?
  137. go into notepad and type this
  138. Quote:
  139. @echo off
  140. echo yay me i know the basics of batch
  141. call call.bat
  142. pause
  143. exit
  144. and save in a new folder:)
  145. then open note pad and type this again
  146. Quote:
  147. @echo off
  148. echo I Love S*X
  149. pause
  150. and save in the same folder that you save the last one... and name it call.bat
  151. launch the first one
  152. this will show
  153. Quote:
  154. yay me i know the basics of batch
  155. I Love S*X
  156. Press Any Key To Continue....
  157. (when you press a key the below will appear)
  158. Press Any Key To Continue...
  159. and when you press a key it will exit
  160. ok.. so now you know what exit does.. it exits the file Imao
  161. and call ,calls in another batch file!!..
  162. so now for SHIFT which is a little hard so try to understand
  163. SHIFT [/n]
  164. If Command Extensions are enabled the SHIFT command supports the /n switch which tells the command to start shifting at the nth argument, where n euh.. can be between zero and eight.
  165. just like this 1 below
  166. SHIFT /2
  167. would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 ..euh.. how can i say it.. .:S.. unaffected yea thats the word .
  168. Examples
  169. the below has got to be saved as .bat.. so just name it test:)
  170. @ECHO OFF
  171. ECHO - %1
  172. SHIFT
  173. ECHO - %1
  174. After creating the above example test.bat file, if you were to type the below command at the MS-DOS prompt, it would print "- ONE" and then "- TWO"; this command is commonly used to work through each of the command extensions or remove command extensions.
  175. (SHIFT , i mean the explanation... i got it from a website and edited it)
  176. Ok I hope you understand
  177. ok thats it for now.. ill post a Batch Features Later
  178. Hello... please read the 2 tutorials before i will talk in this one about a lot of features here we go!:D..
  179. first we will learn how to launch windows applications:
  180. type in notepad:
  181. Quote:
  182. @echo off
  183. echo I am testing notepad!
  184. start /MIN notepad
  185. pause
  186. This will show
  187. Quote:
  188. i am testing notepad
  189. (and notepad will start minimized.. if you put /MAX instead of /MIN it will launch maximized)
  190. Press Any Key To Continue
  191. Now lets learn how to put a timeout inside a batch..
  192. goto notepad and type:
  193. Quote:
  194. @echo off
  195. echo i am trying timeout
  196. set wait=0
  197. :pause1
  198. set /a wait=%wait%+1
  199. if %wait% leq 1000 goto pause1
  200. echo IT WORKED!\
  201. pause
  202. dont understand the command.. just copy paste it.. or memorize it .. if i tell you the explanation it will take years!!..
  203. so this will show :
  204. Quote:
  205. i am trying timeout
  206. (couple of seconds and.. )
  207. Press Any Key To Continue...
  208. Now ill teach you how to change the TIME
  209. goto notepad and type:
  210. Quote:
  211. @echo off
  212. echo Gee!.. i wonder what time it is!!
  213. TIME 5:50
  214. echo Oh so its 5:50
  215. pause
  216. this will show:
  217. Quote:
  218. Gee!.. i wonder what time its is!!
  219. Oh so its 5:50
  220. The TIME will just change The TIME:PImao
  221. Now the Color
  222. go into notepad and type this
  223. Quote:
  224. @echo off
  225. echo trying the colors
  226. pause
  227. color 04
  228. echo testing
  229. pause
  230. color f
  231. echo trying
  232. pause
  233. color 4f
  234. echo trying
  235. pause
  236. 04=background black and font red
  237. f the font will be white
  238. 4f = background red and f = white
  239. Here are the list(that can be found by cmd>color help)
  240. 0=black
  241. 1=blue
  242. 2=green
  243. 3=aqua
  244. 4=red
  245. 5=purple
  246. 6=yellow
  247. 7=white
  248. 8=gray
  249. 9=light blue
  250. a=light green
  251. b=light aqua
  252. c=light red
  253. d=light purple
  254. e=light yellow
  255. f=bright white
  256. So this will show Imao
  257. i wont tell try it!!.:P
  258. now the title
  259. type this in notepad
  260. Quote:
  261. @echo off
  262. tile Test
  263. echo trying the title
  264. pause
  265. this will show the title Test When you launch it!!
  266. lets try Shutdown/Restart
  267. type this in Notepad
  268. Quote:
  269. @echo off
  270. START C:\Windows\RUNDLL.EXE user.exe,exitwindowsexec
  271. exit
  272. The above will restart
  273. Quote:
  274. @echo off
  275. Shut down the computer
  276. C:\Windows\RUNDLL32.EXE user,exitwindows
  277. exit
  278. The Above will Shutdown
  279. Well Thats It.. if i found any more commands.. ill make a new post..
  280. so for now.. those Tutorials Are So VALUABLE

comments powered by Disqus