call batch file with arguments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Xillez
    New Member
    • Jul 2013
    • 93

    call batch file with arguments

    Hey dudes! source code:

    Code:
    @echo off
    color 0a
    
    set /p ip=Enter the ip you want to ping:
    set dataSize=10000
    goto loop
    
    :loop
    	ping %ip% -n 1 -w 1 -l %dataSize%
    	set dataSize=dataSize+dataSize
    	pause
    	start cmd /c ping.bat "%ip%" <---------- parameter
    	goto loop
    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
    Last edited by Rabbit; Apr 8 '15, 03:41 PM. Reason: fixed code tags
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    hi dude..

    if you have a file like this, with name 'test.bat':
    Code:
    @echo off
    echo Hi %1
    when you type 'test Dude' on the command prompt,
    it will answer with 'Hi Dude'

    Or, like this
    Code:
    @echo off
    
    set ip=%1
    if not "%ip%"=="" goto :skipquestion
    set /p ip= Enter the ip you want to ping:
    
    :skipquestion
    echo You entered ip: %ip%

    Comment

    • Xillez
      New Member
      • Jul 2013
      • 93

      #3
      thank you so much man. XD

      Comment

      Working...