batch file/command scrips
Page 1 of 1
batch file/command scrips
here are some batch file's and command scrip tips for those that are interested in such things (I use batch files for my every day tasks, you can even set it up to where a batch file opens programs, inernet sites, etc)
windows 8 batch file creating :
press windows + R simultaneously to start the run command box. Upon the box coming up, type notepad and hit enter. write your code, then save as all files and make shure to put .bat at the end of the file name.
note : MS-DOS Comands are NOT case sensitive
Batch file commands :::
======
@echo off
echo Hello this a test batch file
pause
=======
@ echo off - hides batch file commands in the cmd
@ echo on - shows file commands in cmd
=======
CALL - is used to run another batch file within a batch file.
=======
CLS is used to clear your screen
=======
Exit - exits out of the dos window if the batch file is running from windows
=======
pause - prompts the user to press a key to continue
=======
Rem - one of two ways to add remarks into the batch file without displaying or executing that line when the batch file is run.
=======
Start - used for windows 95, 98, and windows NT 4.0 and abo e to start a windows application; such as START C:\WINDOW\CALC would run the windows calculator. Users running windows 3.x need to utilizie the WIN comand. for example, WIN C:\Windows\Calc.EXE would run windows and then calulator after windows has finished loading.
=======
below is an example of how you can impliement the chocice options into your batch files.
@ECHO OFF
REM - LABEL INDICATING THE BEGINNING OF THE DOCUMENT.
:BEGIN
CLS
REM - THE BELOW LINE GIVES THE USER 3 CHOICES (DEFINED AFTER /C:)
CHOICE /N /C:123 /M "PICK A NUMBER (1, 2, or 3)"%1
REM - THE NEXT THREE LINES ARE DIRECTING USER DEPENDING UPON INPUT
IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE
GOTO END
:THREE
ECHO YOU HAVE PRESSED THREE
GOTO END
:TWO
ECHO YOU HAVE PRESSED TWO
GOTO END
:ONE
ECHO YOU HAVE PRESSED ONE
:END
=========
To use in the command box RUN : START /MAX C:WINDOWS\NOTEPAD.EXE
=========
below is an example of how to delay a batch file any where from 5 seconds to 99 seconds. in the below example we illustrate a 5 second delay.
type
NUL | CHOICE.COM /N /CY /TY,5>NUL
========
to shutdown, reboot, and hibernate, use these codes through the command line :::
to shut down your computer type the command line below:
shutdown.exe /s /t 00
to restart the computer type the below command in the command line :::
shutdown.exe /r /t 00
to hibernate the computer type the command line below :::
shutdown.exe /h
=======
how to play sound files from windows batch files :::
use the start command to start the program associsated with the file. for emple if you wanted to open the player to play "music.mp3" in the command line or batch file you could type the below command.
start music.mp3
if the sound file has a space in the file name, surround the file name in quotes as shown in the below example.
start C:\music\"my song.mp3"
========
Sets the font and background to colors that you choose :::
use the command code "color" then the number and/or letter to change the back ground and font color
=======
changing font colors:::
0 = black
1 = blue
2 = green
3 = aqua
4 = red
5 = purple
6 = yellow
7 = white
8 = gray
9 = light blue
a = light green
b = light aqua
c = light red
d = light purple
e = light yellow
f = bright white
========
windows 8 batch file creating :
press windows + R simultaneously to start the run command box. Upon the box coming up, type notepad and hit enter. write your code, then save as all files and make shure to put .bat at the end of the file name.
note : MS-DOS Comands are NOT case sensitive
Batch file commands :::
======
@echo off
echo Hello this a test batch file
pause
=======
@ echo off - hides batch file commands in the cmd
@ echo on - shows file commands in cmd
=======
CALL - is used to run another batch file within a batch file.
=======
CLS is used to clear your screen
=======
Exit - exits out of the dos window if the batch file is running from windows
=======
pause - prompts the user to press a key to continue
=======
Rem - one of two ways to add remarks into the batch file without displaying or executing that line when the batch file is run.
=======
Start - used for windows 95, 98, and windows NT 4.0 and abo e to start a windows application; such as START C:\WINDOW\CALC would run the windows calculator. Users running windows 3.x need to utilizie the WIN comand. for example, WIN C:\Windows\Calc.EXE would run windows and then calulator after windows has finished loading.
=======
below is an example of how you can impliement the chocice options into your batch files.
@ECHO OFF
REM - LABEL INDICATING THE BEGINNING OF THE DOCUMENT.
:BEGIN
CLS
REM - THE BELOW LINE GIVES THE USER 3 CHOICES (DEFINED AFTER /C:)
CHOICE /N /C:123 /M "PICK A NUMBER (1, 2, or 3)"%1
REM - THE NEXT THREE LINES ARE DIRECTING USER DEPENDING UPON INPUT
IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE
GOTO END
:THREE
ECHO YOU HAVE PRESSED THREE
GOTO END
:TWO
ECHO YOU HAVE PRESSED TWO
GOTO END
:ONE
ECHO YOU HAVE PRESSED ONE
:END
=========
To use in the command box RUN : START /MAX C:WINDOWS\NOTEPAD.EXE
=========
below is an example of how to delay a batch file any where from 5 seconds to 99 seconds. in the below example we illustrate a 5 second delay.
type
NUL | CHOICE.COM /N /CY /TY,5>NUL
========
to shutdown, reboot, and hibernate, use these codes through the command line :::
to shut down your computer type the command line below:
shutdown.exe /s /t 00
to restart the computer type the below command in the command line :::
shutdown.exe /r /t 00
to hibernate the computer type the command line below :::
shutdown.exe /h
=======
how to play sound files from windows batch files :::
use the start command to start the program associsated with the file. for emple if you wanted to open the player to play "music.mp3" in the command line or batch file you could type the below command.
start music.mp3
if the sound file has a space in the file name, surround the file name in quotes as shown in the below example.
start C:\music\"my song.mp3"
========
Sets the font and background to colors that you choose :::
use the command code "color" then the number and/or letter to change the back ground and font color
=======
changing font colors:::
0 = black
1 = blue
2 = green
3 = aqua
4 = red
5 = purple
6 = yellow
7 = white
8 = gray
9 = light blue
a = light green
b = light aqua
c = light red
d = light purple
e = light yellow
f = bright white
========
Ravenna 3arc- Number of posts : 401
Age : 31
Registration date : 2013-10-09
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum