By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,708 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,708 IT Pros & Developers. It's quick & easy.

call batch file with arguments

P: 88
Hey dudes! source code:

Expand|Select|Wrap|Line Numbers
  1. @echo off
  2. color 0a
  3.  
  4. set /p ip=Enter the ip you want to ping:
  5. set dataSize=10000
  6. goto loop
  7.  
  8. :loop
  9.     ping %ip% -n 1 -w 1 -l %dataSize%
  10.     set dataSize=dataSize+dataSize
  11.     pause
  12.     start cmd /c ping.bat "%ip%" <---------- parameter
  13.     goto loop
  14.  
  15.  
  16.  
  17.  
I want to know if there is a way to start a batch file with an arguments, in this case so I don't have to write thei for EVERY window that starts.

Any help would be awsome XD
Apr 8 '15 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,035
hi dude..

if you have a file like this, with name 'test.bat':
Expand|Select|Wrap|Line Numbers
  1. @echo off
  2. echo Hi %1
  3.  
when you type 'test Dude' on the command prompt,
it will answer with 'Hi Dude'

Or, like this
Expand|Select|Wrap|Line Numbers
  1. @echo off
  2.  
  3. set ip=%1
  4. if not "%ip%"=="" goto :skipquestion
  5. set /p ip= Enter the ip you want to ping:
  6.  
  7. :skipquestion
  8. echo You entered ip: %ip%
  9.  
Apr 8 '15 #2

P: 88
thank you so much man. XD
Apr 10 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.