|
Answer» Hello I would like to set options for when I set my batch file,for EXAMPLE "stinger" can be ran with the log option wchich creats a log well I would like to do the same.
Thank You
AlmnI found the command line switches documented on the Stinger page from McAfee:
/ADL - Scan all local drives. /GO - Start scanning immediately. /LOG - Save the log file after scans. /SILENT - Do not display graphical interface.
Google worked for me; it will work for you too! 8-)My question is not with stinger it is on how to create a program that does the same thing as far as options.
AlmnYou're going to have to be more specific. Each computer language HANDLES command line arguments differently, from NAMED or Unnamed Arguments in scripting languages to delimited arguments which can be parsed in compiled languages. Are you writing this program? Is this an existing program?
If you are writing this program you'll have to follow the protocol of the language you're using when dealing with command line arguments. If this is an existing program, it would have been up to the original programmer to allow for command line arguments.
Setting arguments up in batch file is a function of the script or executable you're attempting to run.
Get back to us with more details. 8-)Yes I am "Setting arguments up in batch file is a function of the script or executable you're attempting to run. "
Hope this helps
Almndo you mean like a menu 1=bla 2=bla 3=bla Like that if that is what you mean i think you would use errorlevels No I do not mean like a menue because I know how to do that I mean as options to run the file.
Alexandre
You whant to give Commandline options to the script?
Use something like this: (The options I used are just for example. Except the help....)
@echo off
rem Set local scope and MAIN procedure setlocal & pushd set SCRIPTNAME=%~n0 set SCRIPTPATH=%~f0 set AUTOR=%SCRIPTNAME% Version [ ][Name and Date] set MAILADRESS= [Your Adress] if /i {%1}=={/w} (call :WHATEVER) & (goto :EXIT) if /i {%1}=={/m} (call :MAIN) & (goto :EXIT) if /i {%1}=={/help} (call :HELP) & (goto :EXIT) if /i {%1}=={/h} (call :HELP) & (goto :EXIT) if /i {%1}=={/?} (call :HELP) & (goto :EXIT) :EXIT popd & endlocal goto :EOF
rem ///////////////////////////////////////////////////////////////// rem HELP procedure rem Display brief on-line help MESSAGE rem :HELP
rem Put help message here... cls echo ----------------------------------------------------------------------- echo %AUTOR% echo Your help message echo ..... echo Please send Bugreports to %MAILADRESS% echo ----------------------------------------------------------------------- goto :EOF
rem ///////////////////////////////////////////////////////////////// rem MAIN procedure rem :MAIN rem Put main script code here... goto :EOF
rem ///////////////////////////////////////////////////////////////// rem Additional procedures go here... :WHATEVER
goto :EOF
rem /////////////////////////////////////////////////////////////////
hope this helps uli This question is still ambiguous. Each program that accepts command line parameters does so in DIFFERENT ways.
For instance the Windows DIR command accepts arguments by preceding each with a forward slash. The Windows SHUTDOWN command accepts arguments by preceding each with a minus sign. The Windows NETSH command accepts arguments using no special symbol but rather keywords.
If you write the program, you get to choose how the arguments are understood by the program. If the program was written by someone else, you'd need to use the documentation to find how to feed any arguments (if it's even possible) to the program.
Be aware, not all programs are written to accept arguments.
8-)ok and how would I create an argument that goes to":start" ?
AlmnNormally you wouldn't use an argument, but rather just hardcode it:
goto start . . . :start
But if you really want to use a command line argument, you could try running your batch file and passing the label:
batch.bat start
Inside your batch.bat, you might include this code:
goto %1 . . . :start . . :end
If you pass end on the command line instead of start, you change the flow of the batch file. Batch files can be cryptic as it is. This type of code only leads to more confusion.
|