0

I would like to create a like how we type in CMD with options behind the command. For example cmd shutdown /i Code:

ECHO 1. Nmap
ECHO 2. Nesus
ECHO 3. Nexpose
ECHO ................................

CHOICE /C 123 /M "Enter your choice:"


IF ERRORLEVEL 3 GOTO n
IF ERRORLEVEL 2 GOTO ns
IF ERRORLEVEL 1 GOTO nx

:n
CALL n.bat
GOTO :eof

:ns
CALL ns.bat
GOTO :eof

:nx
CALL nx.bat
GOTO :eof

I would like to transform this into command with options For example: script /n /ns

This will execute the code called script with /n (Nmap) and /ns (Nessus) So that user next time will not need to go through the menu.

and method?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Ivan Sim
  • 305
  • 4
  • 15
  • 1
    Possible duplicate of [Adding switches to command line arguments](http://stackoverflow.com/questions/27497516/adding-switches-to-command-line-arguments) – SomethingDark Apr 13 '17 at 11:13

1 Answers1

0

From another answer of the user in StackOverflow.

It only a method to solve your problem.

Another useful tip is to use %* to mean "all". For example,

echo off
set arg1=%1
set arg2=%2
shift
shift
fake-command /u %arg1% /p %arg2% %*

When you run:

test-command admin password foo bar

the above batch file will run:

fake-command /u admin /p password foo bar
Ave
  • 4,338
  • 4
  • 40
  • 67