# Script access to DOS environment variables?

**URL:** <https://resource.dopus.com/t/script-access-to-dos-environment-variables/18102>\
**Category:** Help & Support\
**Created:** [April 14, 2014, 5:09am UTC](https://resource.dopus.com/t/script-access-to-dos-environment-variables/18102 "2014-04-14T05:09:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aussieboykie](https://resource.dopus.com/user_avatar/resource.dopus.com/aussieboykie/32/23729_2.png) [@aussieboykie](https://resource.dopus.com/u/aussieboykie)\
**Post date:** [April 14, 2014, 5:09am UTC](https://resource.dopus.com/t/script-access-to-dos-environment-variables/18102/1 "2014-04-14T05:09:05Z")

</div>

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.

![](https://resource.dopus.com/uploads/default/original/3X/b/5/b54bf9cf23cc4462e759549d96b44fa57c865b40.png)

Regards, AB

---

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [April 14, 2014, 6:11am UTC](https://resource.dopus.com/t/script-access-to-dos-environment-variables/18102/2 "2014-04-14T06:11:22Z")

</div>

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](https://resource.dopus.com/t/folder-clean-up-and-unrar-scripts-v1-0/17905/1) to read the output from the unrar.exe.

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [April 14, 2014, 6:36am UTC](https://resource.dopus.com/t/script-access-to-dos-environment-variables/18102/3 "2014-04-14T06:36:34Z")

</div>

You can use the FSUtil.Resolve method.

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

---

<div class="post-metadata">

**Author:** ![aussieboykie](https://resource.dopus.com/user_avatar/resource.dopus.com/aussieboykie/32/23729_2.png) [@aussieboykie](https://resource.dopus.com/u/aussieboykie)\
**Post date:** [April 14, 2014, 6:56am UTC](https://resource.dopus.com/t/script-access-to-dos-environment-variables/18102/4 "2014-04-14T06:56:07Z")

</div>

> [@jon](#):
>
> You can use the FSUtil.Resolve method.

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

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 14, 2014, 7:24am UTC](https://resource.dopus.com/t/script-access-to-dos-environment-variables/18102/5 "2014-04-14T07:24:39Z")

</div>

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](http://stackoverflow.com/questions/904739/can-i-pick-up-environment-variables-in-vbscript-wsh-script)

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