Passing more than one parameter to a windows script

Scripts are written in sysadmin to easily perform daily operations. A good practice of code writing is to develop an algorithm based on the process to be performed in such a way that it might be applied to similar operations. To account for this modularity, we have to pass into the script operations values which apply to the specific sysadmin operation we want to perform.

As many other scripting and programming languages, windows scripting handles parameters as part of a script’s calling. However, there is a limit on the number of parameters that can be handled in windows script routines. To overcome this limitation, we can use the SHIFT command inside a conditional IF loop to “extract” as many parameters as we wish to handle.

The following example uses this logic to concatenate a variable number of strings passed as parameters and sets the value of a variable as a large concatenated string:

:LOOP
IF [%2]==[] GOTO LOG_ENTRY
SET EVENTO=%EVENTO% %2
SHIFT /2
GOTO LOOP

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s