I am completeley new with windows batch scripting. I want to write a batch script that gets commandline parameters as below;
myscript -parameter1 param1 -parameter2 param2
It should set parameter1 to param1 and parameter2 to param2 inside the script.
Does anybody have a code block which does the above?
Thanks
You can go through the arguments with a loop and try something like this:
This will look at the arguments one by one and if an argument starts with a
-it will set an environment variable of the same name with the next argument as its value:If you need the original arguments later, then you should move above loop to a subroutine and call it with
%*as arguments.