Deepak Vasudevan
asked on
Arrays in Batch File
Hi,
In a typical DOS Batch file, can we have something like Arrays (like in other programming languages) so that we can read each of the element in the array, prepare a DOS command with this array and execute the same.
I would also like each of the DOS command being executed to wait for the executing command to exit before proceeding to issue the next command.
I can do this in C# but in DOS Batch file I am confused.
In a typical DOS Batch file, can we have something like Arrays (like in other programming languages) so that we can read each of the element in the array, prepare a DOS command with this array and execute the same.
I would also like each of the DOS command being executed to wait for the executing command to exit before proceeding to issue the next command.
I can do this in C# but in DOS Batch file I am confused.
ASKER
Would then having a VBScript file and calling from CScript do the trick.
Basically, I would give you an example:
An array of Fruits like {Apple, Mango, Pomegranete, Banana}
Now I have to call an application like
FruitVendor.exe and pass each of the fruit one at a time. Additionally, while one instance of FruitVendor is running, the loop should wait for exit and then take the next one.
In C#, I can do this as
string[] strFruit = {"Apple", "Mango","Pomegranete", "Banana"};
Then I can use foreach to iterate through this and call Process.Start ("fruitvendor.exe") and pass each of the fruit with WaitForExit() enabled.
The problem is that this needs to be a batch file preferably instead of a compiled application.
Basically, I would give you an example:
An array of Fruits like {Apple, Mango, Pomegranete, Banana}
Now I have to call an application like
FruitVendor.exe and pass each of the fruit one at a time. Additionally, while one instance of FruitVendor is running, the loop should wait for exit and then take the next one.
In C#, I can do this as
string[] strFruit = {"Apple", "Mango","Pomegranete", "Banana"};
Then I can use foreach to iterate through this and call Process.Start ("fruitvendor.exe") and pass each of the fruit with WaitForExit() enabled.
The problem is that this needs to be a batch file preferably instead of a compiled application.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can do a lot with the for command - type for /? at a command prompt for more information on the for command.
It would help if you could give a specific example of what you are looking for.