• Home
  • How to Pass Command Line Parameters to windows Bat File

How to Pass Command Line Parameters to windows Bat File

Hi Friends,

This also gonna be small tutorial.

if you want to pass some parameters to windows bat file.what would you do.

let me explain

first open new text file and type @echo off

in windows environment %0 is file name

let me make you short list this

%0 file name

%1 first parameter

%2 second parameter

%3 Third Parameter

 

Lets go through quick scenario.I have three arguments Python,Perl ,Bash i want to print this as

First Parameter is Python

Second Parameter is perl

Third Parameter is bash

lets create our bat file .i called this lang.bat

Create new test file and

@echo off

@echo First Parameter is %1

@echo Second Parameter is %2

@echo Third Parameter is %3

@echo If you want file name %0

 

now go to save as give name lang.bat and select file type to all.

Open terminal and go to file destination and enter as follow

C:\Users\Sameera\Desktop>lang.bat python perl bash

 

I hope you enjoy this tutorial unless it too short.if you like my website please share on Facebook,Twitter and Google Plus

 

Have a good day

Leave A Comment