# Environment variable use within VBScript action

**URL:** https://www.finalbuilder.com/forums/t/environment-variable-use-within-vbscript-action/2359
**Category:** Discussion
**Created:** [March 18, 2015, 9:29am UTC](https://www.finalbuilder.com/forums/t/environment-variable-use-within-vbscript-action/2359 "2015-03-18T09:29:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kduerksen](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/k/edb3f5/32.png) [@kduerksen](https://www.finalbuilder.com/forums/u/kduerksen)
#### Post date: [March 18, 2015, 9:29am UTC](https://www.finalbuilder.com/forums/t/environment-variable-use-within-vbscript-action/2359/1 "2015-03-18T09:29:04Z")

</div>

I have an environment variable (PROJECTVERSION) set from a Windows batch file prior to that batch file calling FinalBuilder to build my project. Within the various FinalBuilder actions such as TFS get and property set updates I have used that environment variable without a problem. However, when I get to where I have a script action that contains a VBScript I cannot seem to utilized that environment variable or its value–it is always blank. I have tried gathering the environment variables from the user, system, and process levels:  
  
 Set objWSH = &nbsp;CreateObject(“WScript.Shell”)  
Set objUserVariables = objWSH.Environment(“USER”)  
Set objSystemVariables = objWSH.Environment(“SYSTEM”)  
Set objProcessVariables = objWSH.Environment(“PROCESS”)  
  
and trying to get that value several different ways:  
  
&nbsp; BuildVersion = objUserVariables(“PROJECTVERSION”) & “”  
&nbsp; BuildVersion = objSystemVariables(“PROJECTVERSION”) & “”  
&nbsp; BuildVersion = objProcessVariables(“PROJECTVERSION”) & “”  
&nbsp; BuildVersion = createobject(“wscript.shell”).expandenvironmentstrings("%PROJECTVERSION%") & ""

  
with variations of the above both with and without the % symbol. Nothing seems to return its value. Any ideas?  
  
Thanks.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [March 19, 2015, 1:51am UTC](https://www.finalbuilder.com/forums/t/environment-variable-use-within-vbscript-action/2359/2 "2015-03-19T01:51:06Z")

</div>

Environment (and project etc) variables are available in script events, e.g :   
  
 MessageBox FBVariables.COMPUTERNAME,“test”,0   
  
 So you do not need to use WScript.Shell to access them.

---

<div class="post-metadata">

### Author: ![kduerksen](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/k/edb3f5/32.png) [@kduerksen](https://www.finalbuilder.com/forums/u/kduerksen)
#### Post date: [March 19, 2015, 6:28am UTC](https://www.finalbuilder.com/forums/t/environment-variable-use-within-vbscript-action/2359/3 "2015-03-19T06:28:20Z")

</div>

Thank you. Your suggestion along with some further tweaking of the existing VBScript contents got things working as desired.
