5 Cool Batch Files

963K88140

Intro: 5 Cool Batch Files

In This instructable you will get 5 codes for 5 useful batch things

- Password Generator
- Password Protected Command Prompt
- Website Crasher
- Website Pinger
- PC Cleanup Utilities

STEP 1: Password Generator


This Batch generates number only passwords. You can choose from 1, 5. or 10 passowrds to show...all random

Code:

@echo off
:Start2
cls
goto Start
:Start
title Password Generator
echo I will make you a new password.
echo Please write the password down somewhere in case you forget it.
echo ----------------------------------------­-----------------------
echo 1) 1 Random Password
echo 2) 5 Random Passwords
echo 3) 10 Random Passwords
echo Input your choice
set input=
set /p input= Choice:
if %input%==1 goto A if NOT goto Start2
if %input%==2 goto B if NOT goto Start2
if %input%==3 goto C if NOT goto Start2
:A
cls
echo Your password is %random%
echo Now choose what you want to do.
echo 1) Go back to the beginning
echo 2) Exit
set input=
set /p input= Choice:
if %input%==1 goto Start2 if NOT goto Start 2
if %input%==2 goto Exit if NOT goto Start 2
:Exit
exit
:B
cls
echo Your 5 passwords are %random%, %random%, %random%, %random%, %random%.
echo Now choose what you want to do.
echo 1) Go back to the beginning
echo 2) Exit
set input=
set /p input= Choice:
if %input%==1 goto Start2 if NOT goto Start 2
if %input%==2 goto Exit if NOT goto Start 2
:C
cls
echo Your 10 Passwords are %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random%
echo Now choose what you want to do.
echo 1) Go back to the beginning
echo 2) Exit
set input=
set /p input= Choice:
if %input%==1 goto Start2 if NOT goto Start 2
if %input%==2 goto Exit if NOT goto Start 2

STEP 2: Website Pinger

This Batch Pings a website you want and go to it at school

:A
@echo off
Title Website Pinger
color 0e
echo Enter the website you would like to ping
set input=
set /p input= Enter your Website here:
if %input%==goto A if NOT B
echo Processing Your request
ping localhost>nul
echo -------------------------------------------------------------------------------------
echo If you do not clost this in 45 seconds you will go to **ENTER WEBSITE HERE**
echo -------------------------------------------------------------------------------------
ping localhost>nul
echo This is the IP=
ping %input%
set input=
set /p input= If you want to open this adress please enter the IP here:
start iexplore.exe %input%
set input2=
set /p input2=
if %input% exit goto exit
ping localhost -n 45 >nul
start iexplore.exe **ENTER WEBSITE HERE**
exit
:exit
exit


Where it says "**ENTER WEBSITE HERE** put your website...if you dont have one delete both lines

STEP 3: Website Crasher


This site is just like the Website pinger but insted of pinging it crashes it with 1000 data non stop

':A
@echo off
Title Website Crasher
color 0e
echo Enter the website you would like to crash
set input=
set /p input= Enter your Website here:
if %input%==goto A if NOT B
echo Processing Your request
ping localhost>nul
echo To end Crashing press CTRL + C
ping localhost>nul
cls
echo ----------------------------------------------------------------------
echo Now Crashing Website...DO NOT CLOSE THIS BOX!! PRESS CRTL + C TO END!!
echo ----------------------------------------------------------------------
ping %input% -t -l 1000

STEP 4: Password Protected Command Prompt

This Command Prompt makes a user sign up then sign in to get the command prompt

in the command prompt type "red", "green", or "normal" without quotes and it changes the color


@echo off
:home
title Log in to CMD
color 07
cls
echo.
echo Cmd Accounts
echo =============
echo.
echo [1] Log In
echo [2] Sign Up
echo [3] Exit
echo.
set /p op=
if %op%==1 goto 1
if %op%==2 goto 2
if %op%==3 goto 3
goto error
:2
cls
echo Sign Up
echo ======================================
echo.
set /p newname="Enter new username:"
if "%newname%"=="%newname%" goto inputname
:inputname
cd "%userprofile%\documents"
if exist "cmdacoBin" goto skip
if not exist "cmdacoBin" goto noskip
:noskip
md "cmdacoBin"
goto skip
:skip
cd "%userprofile%\documents\cmdacoBin"
if exist "%newname%.bat" goto namexist
if not exist "%newname%.bat" goto skip2
:skip2
echo set realusername=%newname%> "%newname%.bat"
goto next
:next
echo.
set /p pswd=Enter new Password:
if "%pswd%"=="%pswd%" goto inputpass
:inputpass
cd "%userprofile%\documents\cmdacoBin"
echo set password=%pswd%>> "%newname%.bat"
goto next1
:namexist
echo.
echo The entered username already exists.
echo Press any key to return. . .
pause >nul
goto 2
:next1
cls
echo Cmd Accounts
echo ============
echo.
echo Your account has been successfully created!
echo.
pause
goto home
:1
color 07
cls
echo Cmd Accounts Log In
echo ================================
echo.
Set /p logname=Username:
if "%logname%"=="%logname%" goto 2.1
:2.1
echo.
set /p logpass="Password:"
if "%logpass%"=="%logpass%" goto login
:login
cd "%userprofile%\documents\cmdacoBin"
if exist "%logname%.bat" goto call
if not exist "%logname%.bat" goto errorlog
:call
call "%logname%.bat"
if "%password%"=="%logpass%" goto logdone
goto errorlog
:errorlog
color 0c
echo.
echo Username or Password incorrect.
echo Access denied.
pause >nul
goto home
:logdone
cls
echo Command Prompt
echo ==============
echo.
echo Successfully logged in!
echo.
pause
goto account
:account
cls
cd "%userprofile%\documents\cmdacoBin"
call "%realusername%color.bat"
call "%realusername%.bat"
color %colorcode%
cls
echo.
echo -------------------------------------------------------------------------------
echo %realusername%
echo -------------------------------------------------------------------------------
@echo off
break off
Title Command Prompt
color 0a
cls

echo Type "home" any time to go to the current user profile directory.
echo Type "desktop" any time to go to the current user desktop.
echo.
echo Type help to see list of common commands like cd, rd, md, del,
echo ren, replace, copy, xcopy, move, attrib, tree, edit, and cls.
echo Type [command]/? for detailed info.
echo.
pause
cls

:cmd
echo Directory: %CD%
set /P CMD=Command:
if "%CMD%" == "cls" goto cls
if "%CMD%" == "home" goto home2
if "%CMD%" == "desktop" goto desktop
if "%CMD%" == "red" goto red
if "%CMD%" == "green" goto green
if "%CMD%" == "normal" goto normal

%CMD%
cd C:\
goto cmd

:cls
cls
goto cmd

:home2
cd /d %USERPROFILE%
cls
goto cmd

:desktop
cd /d %SystemDrive%\Users\%USERNAME%\Desktop
cls
goto cmd

:red
color 0c
cls
goto cmd

:green
color 0a
cls
goto cmd

:normal
color 07
cls
goto cmd

STEP 5: PC Cleanup Utility

This Batch is my favorate and it will

-Delete Internet cookies
-Delete Temporary Files
-Defrag Disk
-Cleanup Disk

@echo off
title PC Cleanup Utility http://www.youtube.com/user/techki-tv

:menu
cls
echo --------------------------------------------------------------------------------
echo PC Cleanup Utility
echo --------------------------------------------------------------------------------
echo.
echo Select a tool
echo =============
echo.
echo [1] Delete Internet Cookies
echo [2] Delete Temporary Internet Files
echo [3] Disk Cleanup
echo [4] Disk Defragment
echo [5] Exit
echo.
set /p op=Run:
if %op%==1 goto 1
if %op%==2 goto 2
if %op%==3 goto 3
if %op%==4 goto 4
if %op%==5 goto exit
goto error
:1
cls
echo --------------------------------------------------------------------------------
echo Delete Internet Cookies
echo --------------------------------------------------------------------------------
echo.
echo Deleting Cookies...
ping localhost -n 3 >nul
del /f /q "%userprofile%\Cookies\*.*"
cls
echo --------------------------------------------------------------------------------
echo Delete Internet Cookies
echo --------------------------------------------------------------------------------
echo.
echo Cookies deleted.
echo.
echo Press any key to return to the menu. . .
pause >nul
goto menu
:2
cls
echo --------------------------------------------------------------------------------
echo Delete Temporary Internet Files
echo --------------------------------------------------------------------------------
echo.
echo Deleting Temporary Files...
ping localhost -n 3 >nul
del /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*"
cls
echo --------------------------------------------------------------------------------
echo Delete Temporary Internet Files
echo --------------------------------------------------------------------------------
echo.
echo Temporary Internet Files deleted.
echo.
echo Press any key to return to the menu. . .
pause >nul
goto menu
:3
cls
echo --------------------------------------------------------------------------------
echo Disk Cleanup
echo --------------------------------------------------------------------------------
echo.
echo Running Disk Cleanup...
ping localhost -n 3 >nul
if exist "C:\WINDOWS\temp"del /f /q "C:WINDOWS\temp\*.*"
if exist "C:\WINDOWS\tmp" del /f /q "C:\WINDOWS\tmp\*.*"
if exist "C:\tmp" del /f /q "C:\tmp\*.*"
if exist "C:\temp" del /f /q "C:\temp\*.*"
if exist "%temp%" del /f /q "%temp%\*.*"
if exist "%tmp%" del /f /q "%tmp%\*.*"
if not exist "C:\WINDOWS\Users\*.*" goto skip
if exist "C:\WINDOWS\Users\*.zip" del "C:\WINDOWS\Users\*.zip" /f /q
if exist "C:\WINDOWS\Users\*.exe" del "C:\WINDOWS\Users\*.exe" /f /q
if exist "C:\WINDOWS\Users\*.gif" del "C:\WINDOWS\Users\*.gif" /f /q
if exist "C:\WINDOWS\Users\*.jpg" del "C:\WINDOWS\Users\*.jpg" /f /q
if exist "C:\WINDOWS\Users\*.png" del "C:\WINDOWS\Users\*.png" /f /q
if exist "C:\WINDOWS\Users\*.bmp" del "C:\WINDOWS\Users\*.bmp" /f /q
if exist "C:\WINDOWS\Users\*.avi" del "C:\WINDOWS\Users\*.avi" /f /q
if exist "C:\WINDOWS\Users\*.mpg" del "C:\WINDOWS\Users\*.mpg" /f /q
if exist "C:\WINDOWS\Users\*.mpeg" del "C:\WINDOWS\Users\*.mpeg" /f /q
if exist "C:\WINDOWS\Users\*.ra" del "C:\WINDOWS\Users\*.ra" /f /q
if exist "C:\WINDOWS\Users\*.ram" del "C:\WINDOWS\Users\*.ram"/f /q
if exist "C:\WINDOWS\Users\*.mp3" del "C:\WINDOWS\Users\*.mp3" /f /q
if exist "C:\WINDOWS\Users\*.mov" del "C:\WINDOWS\Users\*.mov" /f /q
if exist "C:\WINDOWS\Users\*.qt" del "C:\WINDOWS\Users\*.qt" /f /q
if exist "C:\WINDOWS\Users\*.asf" del "C:\WINDOWS\Users\*.asf" /f /q
:skip
if not exist C:\WINDOWS\Users\Users\*.* goto skippy /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.zip del C:\WINDOWS\Users\Users\*.zip /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.exe del C:\WINDOWS\Users\Users\*.exe /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.gif del C:\WINDOWS\Users\Users\*.gif /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.jpg del C:\WINDOWS\Users\Users\*.jpg /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.png del C:\WINDOWS\Users\Users\*.png /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.bmp del C:\WINDOWS\Users\Users\*.bmp /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.avi del C:\WINDOWS\Users\Users\*.avi /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.mpg del C:\WINDOWS\Users\Users\*.mpg /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.mpeg del C:\WINDOWS\Users\Users\*.mpeg /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.ra del C:\WINDOWS\Users\Users\*.ra /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.ram del C:\WINDOWS\Users\Users\*.ram /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.mp3 del C:\WINDOWS\Users\Users\*.mp3 /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.asf del C:\WINDOWS\Users\Users\*.asf /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.qt del C:\WINDOWS\Users\Users\*.qt /f /q
if exist C:\WINDOWS\Users\AppData\Temp\*.mov del C:\WINDOWS\Users\Users\*.mov /f /q
:skippy
if exist "C:\WINDOWS\ff*.tmp" del C:\WINDOWS\ff*.tmp /f /q
if exist C:\WINDOWS\ShellIconCache del /f /q "C:\WINDOWS\ShellI~1\*.*"
cls
echo --------------------------------------------------------------------------------
echo Disk Cleanup
echo --------------------------------------------------------------------------------
echo.
echo Disk Cleanup successful!
echo.
pause
goto menu
:4
cls
echo --------------------------------------------------------------------------------
echo Disk Defragment
echo --------------------------------------------------------------------------------
echo.
echo Defragmenting hard disks...
ping localhost -n 3 >nul
defrag -c -v
cls
echo --------------------------------------------------------------------------------
echo Disk Defragment
echo --------------------------------------------------------------------------------
echo.
echo Disk Defrag successful!
echo.
pause
goto menu
:error
cls
echo Command not recognized.
ping localhost -n 4 >nul
goto menu
:exit


echo Thanks for using PC Cleanup Utility by Ryan
ping 127.0.0.1 >nul
exit

STEP 6: BYE!!!


Thanks for viewing my 1st instructable and check out my youtube

http://www.youtube.com/techkitv

120 Comments

I want to know how to create simple harmless viruses using.bat files😁
it wont crash the websites i put in
LOLLOLOLOLOLLOLOLOLOLOLOLOLOLOLLOLOOLOLOLOLLOLOLOLOLOL ACORN HEADDDDDDDDDDDDDDD
/give @p written_book{pages:['{"text":"Twisted rights and twisted nights with endless crys no one will weep, five are good we need peace theres only eight of us no one weeps but one must cry","color":"blue","hoverEvent":{"action":"show_text","contents":"Why there weeping nights"}}','["",{"text":"There are to many if your reading this im sure to be ","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":"dead","color":"#FF0005","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":" i dont know you but this is master of the weeping ","color":"reset","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":"lights","color":"#00FF17","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":" i own the ","color":"reset","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":"stars","color":"yellow","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":" of ","color":"reset","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":"light","color":"#00FF17","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":" the ","color":"reset","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":"titans","color":"#FF0003","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":" attacking my town are controlled by master of the dark ","color":"reset","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":"stars","color":"#FF0003","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":", the ","color":"reset","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":"evil","color":"#FF0003","hoverEvent":{"action":"show_text","contents":"Help us"}},{"text":" of it all.","color":"reset","hoverEvent":{"action":"show_text","contents":"Help us"}}]'],title:"broken rights",author:"http://minecraft.tools/brokenrights",generation:3,display:{Lore:["Broken lights"]}}
I updated the Login-Process in CMD so it works better and doesnt show unnecessary text messages; hope you guys like it:

@echo off
:home
title Log in to CMD
color 07
cls
echo Cmd Accounts
echo =============
timeout /t 1 >nul
echo [1] Log In
echo [2] Sign Up
echo [3] Exit
timeout /t 1 >nul
set /p op=
if %op%==1 goto 1
if %op%==2 goto 2
if %op%==3 goto 3
goto error
:2
cls
echo Sign Up
echo ======================================
timeout /t 1 >nul
set /p newname="Enter new username:"
if "%newname%"=="%newname%" goto inputname
:inputname
cd "%userprofile%\documents"
cls
cls
cls
cls
cls
if exist "cmdacoBin" goto skip
if not exist "cmdacoBin" goto noskip
:noskip
cls
md "cmdacoBin"
goto skip
:skip
cd "%userprofile%\documents\cmdacoBin"
cls
if exist "%newname%.bat" goto namexist
if not exist "%newname%.bat" goto skip2
cls
:skip2
echo set realusername=%newname%> "%newname%.bat"
goto next
:next
timeout /t 1 >nul
set /p pswd=Enter new Password:
if "%pswd%"=="%pswd%" goto inputpass
:inputpass
cd "%userprofile%\documents\cmdacoBin"
echo set password=%pswd%>> "%newname%.bat"
goto next1
:namexist
echo.
echo The entered username already exists.
echo Press any key to return. . .
pause >nul
goto 2
:next1
cls
echo Cmd Accounts
echo ============
echo.
echo Your account has been successfully created!
timeout /t 1 >nul
pause >nul
goto home
:1
color 07
cls
echo Cmd Accounts Log In
echo ================================
echo.
Set /p logname=Username:
if "%logname%"=="%logname%" goto 2.1
:2.1
timeout /t 1 >nul
set /p logpass="Password:"
if "%logpass%"=="%logpass%" goto login
:login
cd "%userprofile%\documents\cmdacoBin"
if exist "%logname%.bat" goto call
if not exist "%logname%.bat" goto errorlog
:call
call "%logname%.bat"
if "%password%"=="%logpass%" goto logdone
goto errorlog
:errorlog
color 0c
echo.
echo Username or Password incorrect.
echo Access denied.
pause >nul
goto home
:logdone
cls
echo Command Prompt
echo ==============
timeout /t 1 >nul
echo Successfully logged in!
timeout /t 1 >nul
pause
goto account
:account
cls
cd "%userprofile%\documents\cmdacoBin"
call "%realusername%color.bat"
call "%realusername%.bat"
color %colorcode%
cls
timeout /t 1 >nul
echo -------------------------------------------------------------------------------
echo %realusername%
echo -------------------------------------------------------------------------------
@echo off
break off
Title Command Prompt
color 0a
cls
echo Type "home" any time to go to the current user profile directory.
echo Type "desktop" any time to go to the current user desktop.
echo.
echo Type help to see list of common commands like cd, rd, md, del,
echo ren, replace, copy, xcopy, move, attrib, tree, edit, and cls.
echo Type [command]/? for detailed info.
timeout /t 1 >nul
pause >nul
cls
:cmd
echo Directory: %CD%
set /P CMD=Command:
if "%CMD%" == "cls" goto cls
if "%CMD%" == "home" goto home2
if "%CMD%" == "desktop" goto desktop
if "%CMD%" == "red" goto red
if "%CMD%" == "green" goto green
if "%CMD%" == "normal" goto normal
%CMD%
cd C:\
goto cmd
:cls
cls
goto cmd
:home2
cd /d %USERPROFILE%
cls
goto cmd
:desktop
cd /d %SystemDrive%\Users\%USERNAME%\Desktop
cls
goto cmd
:red
color 0c
cls
goto cmd
:green
color 0a
cls
goto cmd
:normal
color 07
cls
goto cmd

PS: I'm in school yet so dont judge me if it doesn't work please...😂
edited the website pinger code

@echo off
color 0f
:a
cls
set input=
set /p input= Enter web address or ip here:
if %input%==goto A if NOT B
cls
echo Processing request . . .
ping localhost>nul
ping localhost>nul
ping %input%
echo.
echo Press any key to retry . . .
pause >nul
goto a
the link is broken. is there an updated one ?

Make a program that runs a fake virus troll and copies it self
to other computers conected to the network. i'm new to batch and I'm
wondering if this program is possible

This is totally possible since inside of a batch you can make another batch!
If you were to make your virus into a .exe no one would be able to see the code inside which would help your project!

The self replicating part I am not sure how do since the program would have to be open but you could place the program or new bat from the .exe into certain folders

I could make the code for you just get back to me as soon as possible thanks
Did you make it @SomeCoder223 ?
pings site does not crash it
This is because on Windows OS you can only send a certain amount of packets (65000) which is not a lot if you were to make something that had multiple ips and used different device names you could do so
Then that would be considered a Distributed Denial of Service attack. Pinging it to crash it, like this site suggests, is asinine.
The whole login process is so messy there is not rem to separate the ongoing structure of your code

@echo off
title passwordprotected
:beg
echo Hello and Welcome to the home page
echo=====================================
echo.
echo Would you like to:
echo.
echo Log In [1]
echo Sign Up [2]
echo Exit [3]
set /p main=INPUT:
if %main%== 1 goto A
if %main%== 2 goto B
if %main%== 3 goto C
if not %main%== 1 goto error
if not %main%== 2 goto error
if not %main%== 3 goto error
rem ======================================================================================================
:A
cls
echo Hello and Welcome to the Log In Page
echo=====================================
set /p muser=Username:
echo.
if %muser%==%muser% goto check
:check
cd "C:\Users\%USERNAME%\OneDrive\Documents\pwpbin"
if exist %muser%user.txt goto check2
if not exist %muser%user.txt goto error4
:check2
set /p mpass=Password:
if %mpass%==%mpass% goto check3
:check3
cd "C:\Users\%USERNAME%\OneDrive\Documents\pwpbin"
if exist %mpass%pass.txt goto check4
if not exist %muser%user.txt goto error4
:check4
cls
goto done
:done
echo Yay
pause
cls
goto beg
rem ======================================================================================================
:B
cls
echo Hello and Welcome to the sign up page
echo ======================================
echo.
set /p muser=New Username:
if %muser%==%muser% goto match
if %muser%== home goto beg
:pk
set /p mpass=New Password:
if %mpass%==%mpass% goto match2
rem ======================================================================================================
:match
cd "C:\Users\%USERNAME%\OneDrive\Documents"
if exist pwpbin goto loser
if not exist pwpbin goto kool
:kool
md "C:\Users\%USERNAME%\OneDrive\Documents\pwpbin"
goto loser
:loser
cd "C:\Users\%USERNAME%\OneDrive\Documents\pwpbin"
if exist "%muser%user.txt" goto error3
if not exist "%muser%user.txt" goto makeme
:makeme
echo.>C:\Users\%USERNAME%\OneDrive\Documents\pwpbin\%muser%user.txt
goto pk
:match2
md C:\Users\%USERNAME%\OneDrive\Documents\pwpbin
cd "C:\Users\%USERNAME%\OneDrive\Documents\pwpbin"
if exist "%mpass%pass.txt" goto error3
if not exist "%mpass%pass.txt" goto makeme2
:makeme2
echo.>C:\Users\%USERNAME%\OneDrive\Documents\pwpbin\%mpass%pass.txt
cls
goto accreated
rem ======================================================================================================
rem ======================================================================================================
:accreated
echo Awesome Account Has Been Created
pause
cls
goto beg
rem ERROR SECTION ========================================================================================
:error
cls
echo You have done something wrong
pause
cls
goto beg
:error2
cls
echo Wrong Password or Username
echo We will now return you back to Log In
pause
cls
goto A
:error3
cls
echo This Password or Username has been taken use something else
pause
cls
goto B
:error4
echo You entered something wrong in the login page!
pause
cls
goto A
rem ERROR SECTION =========================================================================================



I modified the login process, it had some syntax errors from just pressing enter, pressing space and then enter, and I also added a log to keep track of if you're login in, so you can close the batch file and not have to login again unless you actually logout. I also added a msgbox box using basic VBS scripting so the error messages have a msgbox popup instead of it printing on the screen, it seemed more professional. I've also shortened the login process because there was unnecessary code in the original one. Also, its easier to view the code with Notepad++ if you want to easily look at whats going on.. I made plenty of notes to explain the process and also keep it easier for me to remember and visually see whats going on, its not as easy to view whats going on before you run them on your computer using windows notepad. I hope all of you actually read the code before running it.

-----------------------------------------------------------------------------------------------------------------------------

@echo off

title Login

color 1f

::logs in user who it says is logged in

::Login---------------------------------------------------------------------------------

::Login---------------------------------------------------------------------------------

::Login---------------------------------------------------------------------------------

::Login---------------------------------------------------------------------------------

:home

cls

echo.

echo Accounts

echo.

echo.

echo [1] Log In

echo [2] Sign Up

echo [3] Exit

echo.

echo.

::sets the option to something random to prevent just pressing enter syntax error

set option=njckasldnfvkjasnlkjdfnlkadvn

set /p option=-

if "%option%"=="njckasldnfvkjasnlkjdfnlkadvn" goto homeerror

if "%option%"=="1" goto login

if "%option%"=="2" goto signup

if "%option%"=="3" exit

::Error message

:homeerror

echo msgbox "Error! Invalid Entry." > %tmp%\tmp.vbs

cscript /nologo %tmp%\tmp.vbs

del %tmp%\tmp.vbs

goto home

::Sign Up---------------------------------------------------------------------------------

:signup

cls

echo.

echo Sign Up

echo.

echo.

set /p newname=Enter your new username:

::Checks to see if user already exists

if exist %USERPROFILE%\AccountBin\%newname%\%newname%.bat goto namexists

::Creates directory

md %USERPROFILE%\AccountBin\%newname%

::Changes directory to newly made directory

cd %USERPROFILE%\AccountBin\%newname%

::Creates users username and password in a batch file

echo set realusername=%newname%>> %newname%.bat

echo.

set /p newpassword=Enter your new Password:

echo set logpass=%newpassword%>> %newname%.bat

cls

echo msgbox "Your account has been successfuly created!" > %tmp%\tmp.vbs

cscript /nologo %tmp%\tmp.vbs

del %tmp%\tmp.vbs

goto home

:namexists

cls

echo msgbox "%newname% already exists." > %tmp%\tmp.vbs

cscript /nologo %tmp%\tmp.vbs

del %tmp%\tmp.vbs

goto home

::Login---------------------------------------------------------------------------------

:login

cls

echo.

echo Log In

echo.

echo.

set /p username=Username:

set /p password=Password:

cd %USERPROFILE%\AccountBin\%username%

::Checks to see if User exists

if not exist "%username%.bat" goto loginerror

::Checks the password inside the users batch file

call %username%.bat

if "%password%"=="%logpass%" (

cd %USERPROFILE%\AccountBin\

echo set whosloggedin=%username%>> loggedin.bat

goto account

)

:loginerror

cls

echo msgbox "Username or password is incorrect, please try again." > %tmp%\tmp.vbs

cscript /nologo %tmp%\tmp.vbs

del %tmp%\tmp.vbs

goto home

::Account---------------------------------------------------------------------------------

::Account---------------------------------------------------------------------------------

::Account---------------------------------------------------------------------------------

::Account---------------------------------------------------------------------------------

::Account---------------------------------------------------------------------------------

::Account---------------------------------------------------------------------------------

::Account---------------------------------------------------------------------------------

::Account---------------------------------------------------------------------------------

:account

cd %USERPROFILE%\AccountBin\%realusername%

title %realusername%

cls

echo.

echo What Would You Like To Do %realusername%?

echo.

echo.

echo [1] Logout

echo [2] Exit

echo.

echo.

::sets the choice to something random to prevent just pressing enter syntax error

set choice=njckasldnfvkjasnlkjdfnlkadvn

set /p choice=-

if "%choice%"=="njckasldnfvkjasnlkjdfnlkadvn" goto accounterror

if "%choice%"=="1" goto logout

if "%choice%"=="2" exit

::Error

:accounterror

echo msgbox "Error! Invalid Entry." > %tmp%\tmp.vbs

cscript /nologo %tmp%\tmp.vbs

del %tmp%\tmp.vbs

goto account

:logout

cls

del %USERPROFILE%\AccountBin\loggedin.bat

goto home

More Comments