Sometimes you need to queue rUsers tasks, such as launching application, to prevent resource issues in the Injector machine. So what's the solution?
This is accomplished by using a batch file that will create a file for each user. It will then check how many user files have been created up to that point and send an output of (userfiles*30 seconds) for the wait action to use. This output will vary for each user and will work as a queue.
Before following these steps, make sure the GetWaitTime.bat and ResetQ files are located in the "...\NrgGlobal\Injector\work\test" folder.
Note: The "GetWaitTime.bat" contains the following lines:
for /f %%A in ('dir ^| find "File(s)"') do set cnt=%%A
set /a nb = %cnt% -1
set /a wait = %nb% * 30
copy NUL %USERNAME% >nul
and the "ResetQ.bat" includes:
for /f "eol=: delims=" %%F in ('dir /b /a-d * ^| find /v /i ".bat"') do del "%%F"
Open the scenario and follow the steps below:
1. Add a Run Command line to the beginning of your scenario, component, or on failure section. For the Program/Command Name field add the path of the GetWaitTime.bat file. In the Reg Expression #1 field add #output# for the batch file output variable name. In the Working folder field, add the directory for the file location. For example:
2. Add a Wait action before the action you want to queue the rUsers. In the Time in Seconds field add the variable name (the variable value is "0") used in the Reg Expression #1 field in Step 1, enclose it with % signs. For example:
3. After the Wait action add the Action for the rUsers to perform. In this example, the rUsers will start the notepad application.
4. At the end place a Set a Variable action to use the value [Env USERNAME] for the filename. For example:
5. After this action place a Run Command Line action that will delete the user file that was created for this rUser. In the Program/Command Name add cmd /c DEL %filename%. The text in between the % signs refers to the variable name used for Step 4.
For the working folder add the directory for the GetWaitTime.bat For example: