Book a Demo

Author Topic: System environment variables  (Read 3844 times)

pawelg

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
System environment variables
« on: March 01, 2017, 08:22:51 pm »
Hi, it's my first post on this forum :)
Does anybody know if it's possible to get system variables in VBA script (in EA of course), like Environ("username")?
Thanks for your help.
« Last Edit: March 02, 2017, 01:45:27 am by pawelg »

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: System environment variables
« Reply #1 on: March 02, 2017, 10:47:49 am »
You should be able to call ExpandEnvironmentStrings on the WScript.Shell object.
https://msdn.microsoft.com/en-us/library/dy8116cf(v=vs.84).aspx

Example:
Code: [Select]
'Expand Environment variables such as %TEMP% and %APPDATA%
function ExpandEnvironmentStrings(s)

dim WshShell, retval
retval = ""

set WshShell = CreateObject("WScript.Shell")
if not WshShell is nothing then
retval = WshShell.ExpandEnvironmentStrings(s)
end if

ExpandEnvironmentStrings = retval
end function

Session.Output(ExpandEnvironmentStrings("username=%username%"))

pawelg

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: System environment variables
« Reply #2 on: March 03, 2017, 09:09:39 pm »
Thank you :)