unfortunately it's not possible to pass information between commands but this functionality has been requested by several people before 😉
I see two possible workarounds. You can either write information to a file or database in the first command and then read it out again it the second command or you can build one large command instead of several smaller commands. Both solutions are ugly but I'd prefer the second option (and did this in one case already).
Your idea is creative. I like the out-of-box thinking. A few things to consider.
If you set permanent environment variables (or registry entries 😉 ) on the WFA server, you run the risk of another workflow overwriting it. Also, there could be issues with cleanup later, especially if workflows don't complete successfully. Remember that WFA doesn't have automatic rollback or cleanup.
The easiest and richest way I've done this in WFA is to use a <string><number> naming convention like vol01. The FindChart logic is:
First use a Finder like "Find last volume created in an aggregate (by name prefix)". (Use <string> prefix like 'vol')
For the Found branch, do a Define Volume node and in the name parameter, use the function nextNamePadded( foundVol.name ).
For the Not Found branch, do a Define Volume node and in this name parameter, use a constant describing the starting point "<string>01", like "vol01".
Use the same variable name for both Define Volume nodes. Then, use this volume object variable name to pass to the create volume command (and any subsequent commands or defines, etc.)
This covers both when no volumes with that string pattern exists and when you want to increment to the next number in the list of volumes in an aggregate.
Note: A good practice here is under workflow preferences make sure to check the box for "Consider Reserved Elements" so WFA will reserve the new, unique volume name in the WFA cache right away because you wouldnt want another workflow execution trying to create a volume with the same name. BTW, this is a good reason to create unique volume names with WFA framework instead of inside a command.
Is there a feature request open to have parameters be available for other commands? The other solutions provided are a pain specially when you need to do many workflows. Without this feature you end up creating one huge command to do your stuff and removes a big piece of WFA's purpose. Call them passthrough or global parameters...just and idea.