Some Cool Batch Applications by Sejma
cmdbatchpic.bmp
lets get busy.bmp
This is my first instructable so no complaining!
I'd like to thank neodudeman for his instructables, they helped a lot.

In this instructable i will show you some pretty nifty applications with batch commands.

If you have any problems or changes to request just send me an e-mail at jbell@live.co.za
Leave any feedback in the comment section below.
 
Remove these adsRemove these ads by Signing Up

Step 1: Batch Calculator

cmdcalc.bmp
This is...well... a calculator.
just copy and paste into NOTEPAD and save as calculator.bat
the filename is not important but the extension MUST be saved as " .bat "

@echo off
title Batch Calculator by seJma
color 1f
:top
echo --------------------------------------------------------------
echo Welcome to Batch Calculator by seJma
echo --------------------------------------------------------------
echo.
set /p sum=
set /a ans=%sum%
echo.
echo = %ans%
echo --------------------------------------------------------------
pause
cls
echo Previous Answer: %ans%
goto top
pause
exit
1-40 of 130Next »
Wookie123 says: Apr 3, 2013. 1:58 PM
Free maintenance batch for Windows, just uses utilities built into windows 7 and 8, with 1-click action. Has an installer though. Cleans, defrags, disk checks, updates, checks for malware...etc. User is free to edit it for personal use, make it better...etc :)

OnceOver Maintenance Batch
www.freeOMB.com
X_STOP_X says: Mar 28, 2013. 12:50 PM
this is a folder lock that does hide the folder
cls
@ECHO OFF
title Folder Confidential
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Confidential goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Confidential "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter the Password to unlock folder
set/p "pass=>"
if NOT %pass%== Passwords are hard to crack goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Confidential
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md confidential
echo Confidential created successfully
goto End
:End
g3lrod says: Mar 21, 2013. 1:06 PM
Put this in for a nice little password protect:

Set /a try=0

:begin
set /a try=%try%+1
If %try%==4 GOTO die
Echo Enter your password:
Echo.
Set /p pass="-->"

If %pass%==**PASSWORD** GOTO correct
GOTO begin

:die
Echo Too many incorrect tries
rem (Put some form of punishment here)

:correct

rem Your main code
STEDZ says: Mar 7, 2013. 9:23 AM
@Win7Maniacwhat do you mean by "this sets off the internal alarm in XP and maybe Vista" and what's an"internal alarm"?
g3lrod says: Mar 21, 2013. 12:59 PM
I believe that is the motherboard beeper.
emuman4evr says: Apr 14, 2009. 8:03 PM
Anyone know the command that saves a list of all the files on a hard drive? I want it to basically save the hdd's file tree as a .txt document with the name of the computer and the date in the filename.
Prof. Pickle says: Dec 19, 2012. 8:00 PM
This should work:

TREE C:\ > "Tree.txt"

Then you can either find the file and open it or type in:

START Tree.txt

And then you can either find the file and copy it's contents and then delete it manually OR:

DEL Tree.txt

All of that should work
samkai says: Jan 5, 2011. 5:15 AM
how do you times, plus, and all that?
Prof. Pickle says: Dec 19, 2012. 7:55 PM
The operators in batch scripts are the following:

+ Addition
- Subtration
* Multiplication
/ Division
% Modulus (use %% in batch scripts)
>> and & Bitwise operators
() Grouping
! ~ Unary operators
= *= /= %= += -= &= ^= |= <<= >>= assignment

For more information type "SET /?" in your command prompt.
K'nexFanatiFreek says: Apr 10, 2012. 5:23 AM
@Sejma if you want to carry a message through you must first put echo before it or else cmd will recognize it as an automated command input and you will get a crapload of errors. it will say:

"put message here" is not recognized as an internal or external command or a batch file.

just a little warning for the future
Prof. Pickle says: Dec 19, 2012. 7:50 PM
Really? Come on? Did you even look at the code?
rockin4459 says: Aug 11, 2012. 9:11 PM
I found this nifty batch file that when initially run will create a folder called locker in the same directory as the batch file. put files you want to hide in it and then run the batch file again and it will change it to a control panel shortcut that normally will not be seen unless you have your hidden files unhidden. even then to click it would take you to the control panel. It used to be named Locker.bat, but i renamed it to Systems to deter people from running it. Once you have changed yourpasswordhere to the password you want go get Bat_To_Exe from http://www.f2ko.de/programs.php?lang=en&pid=b2e so that your password can't be discovered. Enjoy

cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto
UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the system (Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo system locked
goto End
:UNLOCK
echo Enter password
set/p "pass=>"
if NOT %pass%==yourpasswordhere goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo system Unlocked successfully
goto End
:FAIL
echo Invalid password
goto UNLOCK
:MDLOCKER
md Locker
echo system created successfully
goto End
:End
WOKANDWAL says: Oct 28, 2012. 10:08 PM
The .bat to .exe converter on http://www.f2ko.de/programs.php?lang=en&pid=b2e hides trojans in the .exe that it makes!!!

DO NOT USE IT!!
Prof. Pickle says: Dec 19, 2012. 7:46 PM
I hear you saying that a lot, what is your proof?
el-xavi26 says: Oct 27, 2012. 4:17 PM
Hey I have seen you have a lot of knowledge in batching. Can you please explain how to add points(numbers) to a amount of points
Prof. Pickle says: Dec 18, 2012. 9:50 PM
What do you mean by this? Are you asking how to add to a pre-existing variable?
Because you used the term "points" I think you are talking about a game.
That would mean that you must add to a variable if (big hint) a certain condition is met.

So:
IF %win% equ 1 set points=%points%+1


That will make the variable "points" go up by one if the variable win is set to one.

Obviously, I didn't have much to go on, but you can use that as a template if you want.
el-xavi26 says: Sep 8, 2012. 1:24 PM
can somebody explain me how to use the set command im really confused
PLEASE ANSWER!!!
Prof. Pickle says: Dec 14, 2012. 11:13 PM
The SET command is one of the most complex commands in batch scripting (other than FOR). Basically, there are three main "versions" of it.

Version one: Just the normal "SET" command, by itself.
When the SET command is by itself, it creates a variable with the value of what you set it as originally. 
Example: SET Variable=Value
To call an all ready call an all ready defined variable, enclose it in percent signs.
Example: ECHO %Variable%
This code would return "Value" onto the screen.

 Version two:The A switch.
The A parameter in the SET command stands for "Algorithm". When it is added, you can use math in a variable.
Example: SET /A Addition=1+1
This would set "Addition" to the value of 2, rather than "1+1" if the A switch was left out.
You can also use this with variables.
Example:
SET Number1=5
SET Number2=15
SET /A Number3=%Number2% / %Number3%

This code will set Number3 as 3, because 15 divided by 5 is 3.

Version three:The P switch.
When the P switch is added to the SET command, it allows a variable to be user-defined.
Example: SET /P User_Defined_Variable=Prompt String: 
This would display "Prompt String", and wait until you enter a value.

There are many other ways to use the SET command, but these are just a few.

Enter the code: "SET /?" in your command prompt for more detailed answers.
sda coba says: Nov 29, 2012. 7:33 AM
This batch should hide the folder and put a password to it. But it doesn't function very well, the folder does hide, but you can put any password and the folder will appear anyway.
What i want to do is to combine the Folder Protector code with the one that hides the folder.. Could someone help me?
I need it so i can hide my games at work haha
Im from Buenos Aires, Argentina

Thanks


Code:

if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-0800 2B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-0800 2B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-0800 2B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==type your password here goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-0800 2B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-0800 2B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End


angusPROD says: Aug 19, 2012. 10:54 AM
its a secure password system that you enter digit by digit
The abort code and password is 1335
Abort code is typed all in one go

***************************
@echo off
title Secure Password
:passeword
Echo password required
set /p CH=
if "%CH%"=="1" goto 1perfect
if not "%CH%"=="1" goto wrong1
:wrong1
Echo wrong
ECho 2 attempts remaining
pause
goto passeword1
:1perfect
Echo Next
set /p QP=
if "%QP%"=="3" goto 3perfect
if not "%QP%"=="3" goto wrong1
:3perfect
Echo next
set /p AD=
If "%AD%"=="3" goto 5perfect
if not "%AD%"=="3" goto wrong1
:5perfect
Echo final one
set /p DM=
if "%DM%"=="5" goto complete
if not "%DM%"=="5" goto wrong1
:passeword1
Echo 2 Attempts remaining
Echo password required
set /p CH=
if "%CH%"=="1" goto 1
if not "%CH%"=="1" goto wrong2
:wrong2
Echo wrong
ECho 1 attempt remaining
Echo Failure to get password
Echo will result in a shutdown
pause
goto passeword2
:1
Echo Next
set /p QP=
if "%QP%"=="3" goto 3
if not "%QP%"=="3" goto wrong2
:3
Echo next
set /p AD=
If "%AD%"=="3" goto 5
if not "%AD%"=="3" goto wrong2
:5
Echo final one
set /p DM=
if "%DM%"=="5" goto complete
if not "%DM%"=="5" goto wrong2
:passeword2
Echo password required
set /p CH=
if "%CH%"=="1" goto 1final
if not "%CH%"=="1" goto wrong3
:wrong3
Echo You have failed to guess the password
ECho You now have 30 seconds to enter the abort code
Echo It is the same as the password
shutdown /s /t 30
Echo **********
set /p SD=
if "%SD%"=="1335" goto abort
if not "%SD%"=="1335" goto end
pause
goto passeword2
:1final
Echo Next
set /p QP=
if "%QP%"=="3" goto 3final
if not "%QP%"=="3" goto wrong3
:3final
Echo next
set /p AD=
If "%AD%"=="3" goto 5final
if not "%AD%"=="3" goto wrong3
:5final
Echo final one
set /p DM=
if "%DM%"=="5" goto complete
if not "%DM%"=="5" goto wrong3
:complete
Echo You made it this far
Echo 1335
Echo Now enter a directory and its ready
Echo made by angusPROD
pause
exit
:abort
shutdown /a
Echo Shutdown aborted
goto passeword2
:end
Echo Goodbye
pause
Exit
yohi9889 says: Apr 4, 2010. 1:00 PM
Hey, here's my edit to the script it changes the number everytime

:R
@echo off
color 0e
title Guessing Game by seJma
set /a guessnum=0
set /a answer=%RANDOM%
set variable1=surf33
echo -------------------------------------------------
echo Welcome to the Guessing Game!
echo.
echo Try and Guess my Number!
echo -------------------------------------------------
echo.
:bottom
echo.
set /a guessnum=0
set /a answer=%RANDOM%
set variable1=surf33
set /p guess=
echo.
if %guess% GTR %answer% ECHO Lower!
if %guess% LSS %answer% ECHO Higher!
if %guess%==%answer% GOTO EQUAL
set /a guessnum=%guessnum% +1
if %guess%==%variable1% ECHO Found the backdoor hey?, the answer is: %answer%
goto bottom
:equal
echo Congratulations, You guessed right!!!
echo.
echo It took you %guessnum% guesses.
echo.
goto R
jayfin says: Aug 17, 2012. 10:19 PM
yohi9889 Your batch file looks good but every time I guess a number it changes.
I typed 9999 and it said lower I typed 9999 again but then it said higher. Is there a way to make it that the numbers don't change until I get it? Can you please email me at jfingerer@ymail.com
Bladesofvengence says: Jul 4, 2012. 7:47 AM
I have a way better version!
WOKANDWAL says: Oct 28, 2012. 10:22 PM
Send it to me in Private Message. I got some pretty good batches as well
electronicz says: May 17, 2012. 4:35 PM
Check out my modified Site Selector. It is a txt file and will have to be saved again as a .bat file.
Bladesofvengence says: Jul 4, 2012. 7:41 AM
basic but nice work!
electronicz says: Aug 2, 2012. 3:04 PM
Thanks
markrosher says: Jul 18, 2012. 10:21 PM
@echo off
cls
:Password
Set Password=
set /p Password= Password:
if %Password%==123 goto YES
if not %Password%==123 goto NO

:YES

Start C:\
Exit

:NO

echo INCORRECT PASSWORD
Set Password=
set /p Password= Password:
if %Password%==123 goto YES
if not %Password%==123 goto NO1

:NO1

Echo INCORRECT PASSWORD
Set Password=
set /p Password= Password:
if %Password%==123 goto YES
if not %Password%==23 goto NO2

:NO2

Echo INCORRECT PASSWORD
Pause
Echo Acces danied
Pause
Exit
GillesM95 says: Mar 23, 2010. 1:10 PM
What does cls stand for ?
Sejma (author) says: Mar 27, 2010. 3:44 AM
Clear Screen, if I'm correct.
K'nexFanatiFreek says: Apr 10, 2012. 5:19 AM
yes, it clears it so that just the C:\users\[YOUR NAME HERE]
\in batch files, it wipes the screen completely clean
Bladesofvengence says: Jul 4, 2012. 7:43 AM
Unless you have @echo off which removes the C:\Users\[YOUR NAME HERE]\
Loganeg says: Oct 20, 2009. 6:30 PM
I'm new to batches, and i could spend a lot of time screwing around with it, but is there any way to mix the "Folder Protector" and this "Site Selector" so that you have to enter your password to get into the site selector?

And of course it popped into to my mind (Half way through the first para.) that i can set the ***ENTER FOLDER PATH HERE*** in the file protector to my site selector batch. posting this anyway.

And I hate attracting attention to myself by writing abnormally long comments but kudos to your first (i think) Instructable! good job.
Bladesofvengence says: Jul 4, 2012. 7:39 AM
That is pretty basic but have fun and if you figured it out yourself before me, at least i tried. I can do way better stuff.
Bladesofvengence says: Jul 4, 2012. 7:35 AM
@echo off
title Password v1.5
color 0a
set /a tries=3
set password=***ENTER YOUR PASSWORD HERE***
:top
echo.
echo ----------------------------------------------
echo.
echo Password
echo.
echo ----------------------------------------------
echo You have %tries% attempts left.
echo Enter password
echo ----------------------------------------------
set /p pass=
if %pass%==%password% (
goto correct
)
set /a tries=%tries -1
if %tries%==0 (
goto penalty
)
cls
goto top
:penalty
echo Sorry, too many incorrect passwords, initiating shutdown.
start shutdown -s -f -t 35 -c "SHUTDOWN INITIATED"
pause
exit
:correct
cls
echo ----------------------------------------------
echo Password Accepted!
echo.
echo Opening Program...
echo ----------------------------------------------
pause
cls
title Site Selector by seJma
:top
echo ***************************************************************
echo.
echo Site Selector
echo.
echo ***************************************************************
echo.
echo Key: [1] Google - Search Engine
echo [2] Hotmail - Mail Server
echo [3] Yahoo - Search Engine/Mail Server
echo [4] Facebook - Social Networking
echo [5] Myspace - Social Networking
echo [6] CNN - News
echo [7] Weather - Weather
echo [8] WikiHow - A How-To Website
echo [9] Instructables - A How-To Website
echo [10] YouTube - Online Videos
echo [11] Answers - Online Encyclopedia
echo [12] Wikipedia - Online Encyclopedia
echo.
echo [e] Exit
echo.
echo ***************************************************************
echo Enter the number of the website which you would like to go to:
echo.
set /p udefine=
echo.
echo ***************************************************************
if %udefine%==1 start www.google.com
if %udefine%==2 start www.hotmail.com
if %udefine%==3 start www.yahoo.com
if %udefine%==4 start www.facebook.com
if %udefine%==5 start www.myspace.com
if %udefine%==6 start www.cnn.com
if %udefine%==7 start www.weather.com
if %udefine%==7 start www.wikihow.com
if %udefine%==9 start www.instructables.com
if %udefine%==10 start www.youtube.com
if %udefine%==11 start www.answers.com
if %udefine%==12 start www.wikipedia.com
if %udefine%==e goto exit

cls
echo ***************************************************************
echo.
echo Thank You for using Site Selector by seJma
echo.
echo ***************************************************************
echo Type [e] to exit or [b] to go back and select another site.
echo.
set /p udefine=
echo.
echo ***************************************************************
if %udefine%==b goto top
if %udefine%==e goto exit
:exit
cls
echo ***************************************************************
echo.
echo Thank You for using Site Selector by SEjMA
echo.
echo ***************************************************************
pause
exit
K'nexFanatiFreek says: Apr 10, 2012. 5:24 AM
(removed by author or community request)
K'nexFanatiFreek says: Jun 2, 2012. 10:57 PM
Never mind the previous statement. Put a :selector address in your code, put the selector in there and have everything related to it redirect to :selector, then just make a goto command in the action sequence of the password protector.
Sejma (author) says: Oct 21, 2009. 11:12 AM
ah yes very good! but if you dont want 2 separate files, what you could also do is insert this code snippet, just under the title, and above :top
***********************************
set /p pass=
if %pass%==YOUR_PASS_HERE (
goto top
) else (
exit
)

***********************************
hope this helps!
kibbleninja says: Dec 10, 2011. 1:24 PM
I turned this into a file selector thanks for these tuts
Win7Maniac says: May 25, 2010. 3:06 PM
Wasn't this taken from TAT?
1-40 of 130Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!