You may also want to look at SETLOCAL and ENDLOCAL commands within a batch script.  They do not do exactly what you want, but they do allow a subscript to be called within the current one, that can set a variable for the current command space, therefore that variable lives until the originating .bat or .cmd file is closed.
This may allow you to pass variables between sub scripts, and not store them permanently.  If you absolutely need permanent variable then setx seems to be the way to go, however you would have to launch a new cmd.exe afterwards to see the variable.