Script access to DOS environment variables?

Is there a way of accessing DOS environment variables like %USERNAME% using the new script interface? The scripting Help seems to suggest that it should be possible but I can't find specifics.


Regards, AB

While I know this is not what you want. I was able to run a DOS command in a script and push the stdout in to a variable which I was then able to parse.
This would be a horrible way to get the output of a simple DOS command like %USERNAME%, but it worked ok for reading the result from an exe that I was running. I used it in this script to read the output from the unrar.exe.

You can use the FSUtil.Resolve method.

Set fs = DOpus.FSUtil DOpus.Output "Hi there, " & fs.Resolve("%USERNAME%") & "!"

Excellent! Maybe a future release of the Help for FSUtil.Resolve could include the fact that environment variables are resolved, as well as folder aliases.

Regards, AB

Remember Windows provides lots of script objects which can also be used in Opus. They aren't in the Opus manual, because the manual is not a guide to VBScript/JScript, but can be found by looking at general sites about Windows scripting or by searching.

e.g. "vbscript environment variables" into Google will get you this:

stackoverflow.com/questions/9047 ... wsh-script

That's arguably a better way to do it as it's reusable outside of Opus.