2012-03-05 9 views
5

Estoy creando un guión que quiero ser de doble propósito:¿Cómo debo usar un script por lotes para crear otros scripts?

  1. el guión utilizar las opciones de entrada del usuario para ejecutar comandos que cambiar algunos ajustes. Esta parte está casi lista.

    • El guión está recogiendo las opciones del usuario en las variables de entorno locales a través de SETLOCAL/ENDLOCAL y SET /P, y llamando a las variables más tarde en el guión de la ejecución del comando.

    • Después de recopilar las opciones de usuario, hay un paso de verificación que muestra esas opciones y le pide confirmación al usuario antes de proceder a la ejecución del comando.

  2. El guión le dará al usuario una opción para crear automáticamente un nuevo guión con sus opciones integradas para el futuro conveniencia.

Aquí es mi concepto de plan actual para alcanzar el objetivo nº 2, aunque no estoy muy seguro de cómo se escribe:

  1. Construir un script de plantilla que se puede copiar para empezar creación de los scripts personalizados.

    • En el comienzo de la secuencia de comandos de plantilla, SETLOCAL aislará variables de entorno creado por el guión finalizado por lo que no persisten después de que el script se termina de ejecutarse.

    • Inmediatamente después de SETLOCAL será un comando GOTO que apunta a una etiqueta al final del script. La etiqueta será el comienzo de la sección de definiciones de variables en las secuencias de comandos completadas.

    • Después del comando GOTO habrá una etiqueta llamada STARTEXEC que se saltará después de que se completen las definiciones de variables.

    • Justo antes de que la etiqueta de la sección de variables sea una sección etiquetada con algunos comandos para salir del script.

  2. en el script actual:

    • Añadir un CHOICE durante la etapa de verificación que pregunta al usuario si les gustaría crear un script estático. En caso afirmativo, solicite al usuario un nombre de archivo a través del SET /P y luego incluya los comandos de creación del script en el flujo de ejecución de este script a través del GOTO.
       
  3. uso de algunos comandos similares a éstos, para construir sección de variables del script estática:

    COPY ScriptTemplate.bat %UserFileName%.bat
    ECHO SET VAR1=%UserVar1% >> %UserFileName%.bat
    ECHO SET VAR2=%UserVar2% >> %UserFileName%.bat

  4. Añadir una línea más para asegurarse de que la estática la secuencia de comandos salta a la ejecución del comando.

    ECHO GOTO STARTEXEC >> %UserFileName%.bat

Mis preguntas aquí:

  1. son mis métodos bastante sólido, o hay una mejor manera de hacer esto, aún a través de comandos por lotes?

  2. ¿Qué debo usar para salir del script estático, antes de que regrese a la sección de variables? Sé que necesitaré un ENDLOCAL. ¿Funcionará aquí el EXIT, o hay algo más apropiado para esto?

+0

¿Está limitado a un archivo por lotes? – Mechaflash

+0

@Mechaflash Solo según mi nivel actual de conocimiento y experiencia, pero sí. El alcance de esta pregunta está limitado solo a los archivos por lotes. – Iszi

+0

He dado una respuesta, sin embargo, sugeriría buscar AutoIT para proyectos como este en el futuro. Es bastante fácil de recoger, y parece lo suficientemente competente. – Mechaflash

Respuesta

0

Iszi,

Tengo una función similar que hacemos en mi trabajo ... tenemos un conjunto diferente de variables personalizadas que utilizamos para dar inicio a otras funciones por cliente nos ocupamos. He escrito una secuencia de comandos compleja con Batch que me permite a mí y a mis compañeros de trabajo lograr esto, sin embargo, crear un archivo de lote por separado nunca es necesario en mi opinión.

Hay 2 maneras que consideran necesario para lograr lo que estás buscando:

  1. Puede configurar todas las variables en el comienzo y editarlos desde allí

  2. Puede pedirá las variables de cada tiempo/escribir un nuevo guión

cualquier manera de hacer esto de escribir un archivo por lotes para escribir otro archivo por lotes es tonta y deja todo tipo de potencial por error en el código. No solo estará haciendo una comprobación de errores en un script por lotes, sino que tendrá otro.

Así que aquí están algunos ejemplos de lo que puede hacer:

1.

@ECHO off 
TITLE Install Script 
COLOR 0A 
SETLOCAL 

REM --------------------------- 
REM *** EDIT VARIABLES BELOW *** 
REM --------------------------- 

:sharepath 
set sharepath=\\SCIncapps\sharepath 
REM SHAREPATH = The location of the files that will be copied to the client machine. List of files you will need in your SCIncIntViewer folder: 
REM vcredist_x86.exe, msxml6.msi, Browser Access Client Controls.msi, Automated Update Service.msi, bac.ico, dotnetfx35.exe, dotNetFx40_Full_x86_x64.exe, Episys Client.msi 
REM This Sharepath is where the Script needs to be located and has to be an already existing directory 

:primaryStaging 
set primaryStaging=SCIncweb 
REM primaryStaging = The name of the back office server that handles AutoUpdate. This is usually the same as websrvr, except in distributed environments 

:webserver 
set websrvr=SCIncweb 
REM websrvr = The name of the Web Server; i.e. SCIncweb, SCInc14Doc1, 10.1.1.1, 192.168.1.20, etc. 

:install_variables 
set dotnet35=F 
REM Defines the installation of .NET 3.5 SP 1 as True(T) or False(F) 
set dotnet40=F 
REM Defines the installation of .NET 4.0 as True(T) or False(F) 
set regedit=F 
REM Defines the creation of the Registry File to edit all IE settings as True(T) or False(F) 
set SSL=F 
REM Defines the use of SSL for the BAC URL; SSL is set as True(T) or False(F) 
set org=0000 
REM Defines the Organization for the BAC url shortcut that is created on the desktop for all users (enter the numeric org #) 
set favorite=T 
REM This will put the Browser Access Client URL in their favorite folder and on their browser's quick link bar as True(T) or False(F) 
set reboot=F 
REM Defines whether or not the script will reboot the machine after it's complete as True(T) or False(F) 
REM If using the PsExec.exe to push this script this will force the Domain Administrator to logoff the machine 
set reloadAll=F 
REM This defines if the _Installed_Files.txt will be overwritten to install all products again as True(T) or False(F) 
REM NOTE This will copy down all items and install everything except .NET 3.5 SP1 and .NET 4.0 

:creditUnion_Variables 
set episys=F 
REM Defines the installation of Episys Integration for as True(T) or False(F) 

:bank_Variables 
set silver2020=F 
REM Defines the installation of SCInc Integration for as True(T) or False(F) 
set coreDirector=F 
REM Defines the use of Core Director for banks as True(T) or False(F) 
set iseries=1.1.1.1 
REM Defines the IP address of the iSeries if in-house Some Company, Inc Core, otherwise irrelevant 
set dualinQuiry=F 
REM Defines the deletion of the old SCInc Viewer if NOT using Dual Inquiry as True(T) or False(F) 
set thinClient=F 
REM Defines the /install and /execute flags on a Terminal Server as True(T) or False(F) 
set vportsPath=%sharepath% 
REM Defines the vports.xml file's location, this variable should be kept as the sharepath unless the client specifies otherwise 

:Logs 
set PCaudit=T 
REM Defines whether or not you want just the PC name to be logged to a file as True(T) or False(F) 
REM Creates a list of all the PC's that this script has been run on and puts it in the sharepath folder 

REM --------------------------- 
REM *** DO NOT EDIT BELOW *** 
REM --------------------------- 

IF /I '%scanStation%'=='T' goto:eof 
REM If running the Scan Station Install tool only the variables are read and then the Scan Station Install Tool.bat will resume 
goto thinClient_inst 

:thinClient_inst 
IF /I '%thinClient%'=='F' goto date_time 
change user /install 

:date_time 
FOR /F %%A IN ('TIME/T') DO SET time=%%A 
REM Sets the time in a proper format for Error Logging 
FOR /F "tokens=1-4 delims=/ " %%B IN ('DATE /t') DO SET date=%%C/%%D/%%E 
REM Sets the date in a proper format for Error Logging 

:errorLog 
REM Logs the error messages for each product that the script attempts to install 
IF exist %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt goto PCaudit 
echo.Microsoft Website for Errors:> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt 
echo.http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt 
echo.(Popular Error: 9009, 1616 :: File does not exist in directory)>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt 
echo.--------------------------------------------------------------->> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt 
set cleanInstall=0 
REM Checks if the ErrorLog file already exists, if not it writes the fist 2 lines which contain the URL for determining the Errors from Microsoft 
goto PCaudit 

:PCaudit 
REM Logs the Computer Name to the Installed_PC text file 
REM This checks to make sure that the PC name doesn't already exist in that file and if it does it puts it into another file called %org%_ _Repeat_Installs_Log.txt 
verify >nul 
IF /I '%PCaudit%'=='f' set PCaudit=F 
IF /I '%PCaudit%'=='F' goto start 
IF /I '%PCaudit%'=='t' set PCaudit=T 
set repeat=F 
findstr /x "%computername%" %sharepath%\%org%_ _Installed_PCs_AuditList.txt 
IF '%ERRORLEVEL%'=='0' set repeat=T 
IF /I '%repeat%'=='T' echo.%date% - %time% - %computername%>> %sharepath%\%org%_ _Repeat_Installs_Log.txt 
IF /I '%repeat%'=='T' goto start 
IF /I '%repeat%'=='F' echo.%computername%>> %sharepath%\%org%_ _Installed_PCs_AuditList.txt 
goto start 

:start 
REM Changes all variables for True(T) and False(F) to capital letters since batch is case sensitive 
set HKEY=HKEY_LOCAL_MACHINE 
REM This script is meant to be run by a user with ADMIN privledges; 
REM " HKEY_LOCAL_MACHINE " registry items can only be edited by an admin 

:_done 
IF NOT exist "c:\SCInc\ \_done" md c:\SCInc\ \_done 
IF NOT exist "c:\SCInc\ \_done\ _Installed_Files.txt" echo. Installed Files for %computername%: > c:\SCInc\ \_done\ _Installed_Files.txt 
IF /I '%reloadAll%'=='T' echo. Installed Files: > c:\SCInc\ \_done\ _Installed_Files.txt 
goto iviewerUrl 
REM Creates the _done folder and the _Installed_Files.txt which will be local to the PC and will keep the products they install to prevent reinstallation 
REM Delete this folder to reinstall all products or delete the line of text inside to reinstall a particular product 

:iviewerUrl 
set iviewerUrl=http://%websrvr% 
IF /I '%SSL%'=='T' (set iviewerUrl=https://%websrvr%) 
REM This sets the 'iviewerUrl' variable depeneding on if you have SSL enabled or not 
set SCIncUrl=/bac/user/User_SO.asp?%OrgName= 
REM This sets the rest of the URL for the browser shortcut (the '?' doesn't get a long with batch scripts) 

:copy 
REM Copies the files from the sharepath to the local machine 
echo. 
echo.Copying Necessary Files for Installation 
echo.This could take a few minutes... 
md C:\SCInc\ 
md C:\SCInc\Temp 
REM Creates the ' \SCInc\ ' and ' \SCInc\Temp ' directories 
goto 1 

:1 
verify >nul 
findstr /x "copy_vcredist" "c:\SCInc\ \_done\ _Installed_Files.txt" 
IF '%ERRORLEVEL%'=='0' goto 2 
echo.Copying vcredist_x86.exe 
copy %sharepath%\vcredist_x86.exe c:\SCInc\temp 
REM Copies the C++ Redistributable installer 
IF '%ERRORLEVEL%'=='0' echo.copy_vcredist>> C:\SCInc\ \_done\ _Installed_Files.txt 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error copying vcredist_x86: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 
goto 2 
:2 
verify >nul 
findstr /x "copy_msxml6" "c:\SCInc\ \_done\ _Installed_Files.txt" 
IF '%ERRORLEVEL%'=='0' goto 3 
echo.Copying msxml6.msi 
copy %sharepath%\msxml6.msi c:\SCInc\temp 
REM Copies MSXML 6.0 Parser installer 
IF '%ERRORLEVEL%'=='0' echo.copy_msxml6>> C:\SCInc\ \_done\ _Installed_Files.txt 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error copying msxml6.msi: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 
goto 3 
:3 
verify >nul 
findstr /x "copy_BAC" "c:\SCInc\ \_done\ _Installed_Files.txt" 
IF '%ERRORLEVEL%'=='0' goto 4 
echo.Copying Browser Access Client Controls.msi 
copy %sharepath%\" Browser Access Client Controls.msi" C:\SCInc\temp 
REM Copies the Browser Access Client Controls installer 
IF '%ERRORLEVEL%'=='0' echo.copy_BAC>> C:\SCInc\ \_done\ _Installed_Files.txt 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error copying Browser Access Client Controls.msi: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 
goto 4 
:4 
verify >nul 
findstr /x "copy_AutoUpdate" "c:\SCInc\ \_done\ _Installed_Files.txt" 
IF '%ERRORLEVEL%'=='0' goto 5 
echo.Copying Automated Update Service.msi 
copy %sharepath%\" Automated Update Service.msi" C:\SCInc\temp 
REM Copies the Automated Update Service installer 
IF '%ERRORLEVEL%'=='0' echo.copy_AutoUpdate>> C:\SCInc\ \_done\ _Installed_Files.txt 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error copying Automated Update Service.msi: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 
goto 5 
:5 
verify >nul 
findstr /x "copy_icon" "c:\SCInc\ \_done\ _Installed_Files.txt" 
IF '%ERRORLEVEL%'=='0' goto copy_dotnet35 
echo.Copying BAC Icon 
copy %sharepath%\bac.ico %windir%\System32 
REM Copies the Browser icon file to the System32 folder 
IF '%ERRORLEVEL%'=='0' echo.copy_icon>> C:\SCInc\ \_done\ _Installed_Files.txt 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error copying bac.ico: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 
echo. 
echo.Created the following directories: 
echo.------------------------------------------------------- 
echo. 
echo.C:\SCInc\ 
echo.C:\SCInc\Temp 
echo. 
echo.------------------------------------------------------- 
goto copy_dotnet35 

:copy_dotnet35 
verify >nul 
REM Copies .NET 3.5 Service Pack 1 
reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5"| findstr Install 
REM Checks for .NET 3.5 and installs it if it doesn't find it 
IF '%ERRORLEVEL%'=='0' set dotnet35=F 
IF /I '%dotnet35%'=='F' goto copy_dotnet40 
echo.Copying and installing .NET 3.5 Service Pack 1 
echo.This will take a few minutes... 
copy %sharepath%\dotnetfx35.exe C:\SCInc\Temp 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error copying .NET 3.5 SP1: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 

:dotnet35 
verify >nul 
REM Installs .NET 3.5 Service Pack 1 
echo.Installing .NET 3.5 Service Pack 1 
echo.This could take a few minutes... 
c:\SCInc\temp\dotnetfx35.exe /q /norestart 
IF '%ERRORLEVEL%'=='0' echo.dotnet35>> C:\SCInc\ \_done\ _Installed_Files.txt & set net35=1 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error completing the installation of .NET 3.5 SP1: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 
echo. 
echo.------------------------------------------------------- 
echo. 
goto copy_dotnet40 

:copy_dotnet40 
verify >nul 
REM Copies .NET 4.0 
reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"| findstr Install 
REM Checks for the FULL (not client) version of .NET 4.0 and installs it if it doesn't find it 
IF '%ERRORLEVEL%'=='0' set dotnet40=F 
IF /I '%dotnet40%'=='F' goto msxml60 
echo.Copying and installing .NET 4.0 
echo.This could take a few minutes... 
copy %sharepath%\dotNetFx40_Full_x86_x64.exe c:\SCInc\temp 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error copying .NET 4: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 

:dotnet40 
verify >nul 
REM Installs .NET 4.0 
echo.Installing .NET 4.0 
echo.This could take a few minutes... 
c:\SCInc\temp\dotNetFx40_Full_x86_x64.exe /q /norestart 
IF '%ERRORLEVEL%'=='0' echo.dotnet40>> C:\SCInc\ \_done\ _Installed_Files.txt & set net40=1 
IF NOT '%ERRORLEVEL%'=='0' echo.%date% - %time% - %computername% - There was an error completing the installation of .NET 4: Error Code %errorlevel%>> %sharepath%\%org%_ _Installed_PCs_ErrorLog.txt & set cleanInstall=1 
goto msxml60 

Por encima de la escritura es parcial y se editó.

Como puede ver, configuré todas mis variables al principio de mi archivo. De esta forma, cada vez que necesito cambiar algo, nunca voy al código para hacerlo, lo mismo con mis compañeros de trabajo. Algunos de ellos son capaces de cambiarlo, otros no, y no es fácil entender qué cambiar, ya que todo está ubicado en las primeras 70 líneas del archivo. La razón por la que creo que este es el mejor camino a seguir es porque tengo la flexibilidad de cambiar las cosas sobre la marcha.Tengo variables que desencadenan otras instalaciones que podría querer realizar más tarde. Con una secuencia de comandos que crea otra secuencia de comandos, es posible que carezca de la capacidad de cambiar las cosas sin volver a ejecutar su primer archivo por lotes.

@echo off 
> usermessage.vbs ECHO WScript.Echo InputBox("What is the name of the Service you want to restart?", "Service:", "MspSvc") 
FOR /F "tokens=*" %%A IN ('CSCRIPT.EXE //NoLogo usermessage.vbs') DO SET Service=%%A 
ECHO You will restart %Service% 
DEL usermessage.vbs 

net stop %Service% 
net start %Service% 

Pause 

Esto es de Rob Vanderwoude. Es probable que tenga el sitio web más utilizado para los comandos de script por lote que conozco. He alterado esta pieza para tomar la entrada del usuario y usar eso para escribir mi variable para reiniciar los servicios. Esto podría funcionar para lo que quieres hacer para escribir un guión que escribe otro script ..

Si este es el caso, entonces lo que vas a querer hacer es lo siguiente:

@ECHO off 
TITLE Script Creator 
COLOR 0A 
SETLOCAL 

> usermessage.vbs echo.WScript.Echo InputBox("Pick something to test SETLOCAL/ENDLOCAL on?", "Variable:", "OUTSIDEVARIABLE") 
FOR /F "tokens=*" %%A IN ('CSCRIPT.EXE //NoLogo usermessage.vbs') DO SET outsideVar=%%A 
echo.Your variable is %outsideVar% 
DEL usermessage.vbs 

echo.%outsideVar% is still set outside 

[email protected] off>c:\temp\newbatch.bat 
echo.COLOR 1B>>c:\temp\newbatch.bat 
echo.SETLOCAL>>c:\temp\newbatch.bat 
echo.cls>>c:\temp\newbatch.bat 
echo.set insideVar=%%outsideVar%% >>c:\temp\newbatch.bat 
echo.^> usermessage.vbs echo.WScript.Echo InputBox("Pick something to test SETLOCAL/ENDLOCAL on?", "Variable:", "INSIDEVARIABLE") >>c:\temp\newbatch.bat 
echo.FOR /F "tokens=*" %%%%A IN ('CSCRIPT.EXE //NoLogo usermessage.vbs') DO SET insideVar=%%%%A >>c:\temp\newbatch.bat 
echo.DEL usermessage.vbs >>c:\temp\newbatch.bat 
echo.echo.Your variable is %%insideVar%% >>c:\temp\newbatch.bat 
echo.echo.You have set the Second Variable: %%insideVar%% in this new batch file! >>c:\temp\newbatch.bat 
echo.echo.%%insideVar%% is now Inside the new batch >>c:\temp\newbatch.bat 
echo.Pause >>c:\temp\newbatch.bat 
echo.ENDLOCAL >>c:\temp\newbatch.bat 

echo.You are about to run the new batch file 
pause 
call c:\temp\newbatch.bat 

cls 
pause 
echo.You created a batch file that set your outsideVar variable in it 
echo.%outsideVar% is still set outside 

ENDLOCAL 
REM Install Batch Script 
REM Created by Trevor G. 

En este script tenemos una manera única de asegurarnos de que cada línea se escriba al final de la nueva secuencia de comandos por lotes, pero también debe recordar las cosas clave aquí ... hay momentos en los que necesitará usar^(quilates) y momentos en los que necesitará doblar su %% para asegurarse de que se pasen sus dos variables y que no esté activando otro comando dentro de su script antes de escribirlo en el nuevo.

+0

Su script es * manera * demasiado largo. Por favor, reduzca el ejemplo a una subsección relevante para mostrar su respuesta. No necesita el script * completo *. Además, no publique * otra * respuesta como continuación, esto se considera * ruido * y se eliminará como tal. Si no puede encajarlo en una respuesta, entonces es una buena indicación de que ha dicho * demasiado *. – casperOne

+3

Y definitivamente * queremos * que sea útil, pero también queremos que todos aspiren a un nivel de calidad que ayude * a todos *; Dicho esto, no es la respuesta * mala *, pero se puede * mejorar * y siempre queremos que los usuarios de SO * mejoren las cosas *. Mire su respuesta, vea qué es * realmente necesario * (en lugar de un volcado de código con muchas partes irrelevantes) y reduzca a eso; encontrará que será * mucho * mejor recibido (en forma de votos ascendentes). – casperOne

+0

Además, tenga en cuenta que el "Espero que esto ayude" y la parte de la firma de su mensaje deben ser editados, como se explica [aquí] (http://stackoverflow.com/faq#signatures). – Laf

1

La idea de la plantilla parece ser el método fácil (no estoy seguro acerca del corto, pero probablemente así lo haya abordado). Cree una plantilla separada basada en el original, eliminando todos los comandos SET/P.

EDITAR:

Se ha eliminado la respuesta anterior.

Al final de la plantilla, escribe:

GOTO:EOF 

:User_Defined_Variables 

Al principio del archivo, escriba:

CALL:User_Defined_Variables 

En el guión original, después de que el usuario confirma la creación de un script personalizado, haga una copia del archivo de plantilla COPY /y template.bat userscript.bat envíele todas las variables del usuario.

(ECHO var1 = %uservar1% 
ECHO var2 = %uservar2% 
Echo var3 = %uservar4%)>> userscript.bat 
GOTO:EOF 

Así, cuando el usuario ejecuta la secuencia de comandos, la llamada: User_Defined_Variables fijará parámetros de script del usuario y continuar con el resto de la secuencia de comandos.

+0

Buena idea, pero estoy confundido sobre cómo funcionará el ciclo. (Los bucles nunca fueron mi fuerte). Particularmente, parece que solo va a funcionar para un número específico de líneas. ¿Qué pasa si el número de líneas será variable? (Algunas configuraciones de usuario requerirán que todas las variables se definan, otras no). Por eso pensé que sería más fácil usar '>>' para poner las variables al final, y 'GOTO' para saltar el resultado secuencia de comandos según sea necesario. – Iszi

+0

Dame un fragmento de código (simplemente actualiza tu publicación original) donde pides al usuario que ingrese, y qué comando se ejecuta en función de la entrada, y puedo crear un ejemplo real. – Mechaflash

+0

Cambié mi respuesta por completo. – Mechaflash

Cuestiones relacionadas