How to Make a Set of Random Variables in Batch
- 1). Click on "My Computer" and click on the "C:" drive to open it.
- 2). Right-click anywhere in the "C:" drive and select "New/Folder" to create a folder on the root of the "C:" drive. Name it whatever you want.
- 3). Click on the new folder to enter it.
- 4). Right-click anywhere in the new folder and select "New/Text File" to create a blank text file. Name this file "test.bat."
- 5). Right-click "test.bat" and select "Edit." The default text editor for your system opens the file.
- 6). Enter the following statement into the text editor to generate a variable and assign it a random number:
set var0 = %random% - 7). Repeat the previous step a few more times, increasing the number following "var" one each time (e.g. var1, var2, var3). Do this until you are satisfied that your set of variables is large enough.
- 8). Save the file by pressing "Ctrl" and "S" simultaneously.
- 9). Double-click on the "test.bat" file to execute it. The file creates several variables and assigns random numbers to them. An example of what the output might look like is shown below:
C:\>set var0 = 15387
C:\>set var1 = 19220
C:\>set var2 = 8940
C:\>set var3 = 12042
Source...