Batch programming

@echo off

echo Hello master.

timeout 2 >nul

echo I am setting up the system ...just give me 5 sec

timeout 5 > nul

start C:\"Program Files"\JetBrains\"PyCharm Community Edition 2020.2.1"\bin\pycharm64.exe

start C:\"Program Files"\JetBrains\"IntelliJ IDEA Community Edition 2020.2.1"\bin\idea64.exe

start www.blogger.com

start www.youtube.com

echo SETUP COMPLETE.

timeout 2 >nul

echo System is all set Master, Happy Working :)

pause >nul


ABOVE CODE OPENS UP APPS & LINKS

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


Useful sites : 


https://www.text-image.com/convert/ - Can be used to create TEXT IMAGES 


1] Contains all Batch Commands - https://ss64.com/nt/  (A - Z of batch )


2]  Contains most used Batch commands - http://www.trytoprogram.com/batch-file-commands/


3] Insane things to do : https://securitydiaries.com/11-insane-things-can-batch-programming/


4] Delays in batch file : 

https://www.robvanderwoude.com/wait.php#:~:text=tab%20or%20window.-,PAUSE,Ctrl%2C%20Shift%2C%20NumLock%20etc.




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

NOTES :


If you want to learn about a particular keyword , use the "/?" . For example :  if/?


The Batch file scripting keywords are case insensitive.




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


http://www.trytoprogram.com/batch-file-commands/#echo

Above link also explains all in good.


COMMANDS : 


1]  echo - used to print the message on the screen.


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


2] pause - Holds the screen until any key is pressed. If you dont give Pause at the end of the File, then the File will Close very fast and you wont be able to see anything.


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


3] @echo off - this command hides the command itself from appearing on the screen.

Example code below :

@echo off

echo Hello Fucker

pause


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


4] Exit - terminates the console window


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


5]  This might be the one of the most important batch file commands because with this HELP command we can know about all the other commands used in batch file or command prompt.

Example

@echo OFF
HELP


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


6]  PING


The batch command PING is used for sending ICMP/IP packets to the designated address over the network.

Example

@echo OFF
PING 127.0.1.1


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


7] REM (comments)

Example

@echo off 
Rem This program just displays Hello World 
set message=Hello World 
echo %message%


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


8]  SET - used to set variables


@echo off 
set message=Hello World 
echo %message%

use "/A" if the value is numeric.

SET /A a = 5 


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


9]  

  1. The percent sign is used in batch files to represent command line parameters: %1%2, ...
  2. Two percent signs with any characters in between them are interpreted as a variable:

    echo %myvar%


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


10]  START - used to open web pages & applications.

Click link to know more : https://www.computerhope.com/issues/ch001345.htm


If the file path contains a space within a folder name, you need to enclose that folder name in double quotes. For example, if you had Google Chrome installed on your computer and wanted to start the Chrome browser through a batch file, you could use the command below.

START C:\"Program Files (x86)"\Google\Chrome\Application\chrome.exe


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


11]  IF ELSE -

syntax :  If (condition) (do_something) ELSE (do_something_else)


@echo off 
SET /A a = 5 
SET /A b = 10
SET /A c = %a% + %b% 
if %c%==15 (echo "The value of variable c is 15") else (echo "Unknown value") 
if %c%==10 (echo "The value of variable c is 10") else (echo "Unknown value")


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


useful blog : http://www.trytoprogram.com/batch-file-for-loop/


12]  LOOPS -














Comments