Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Can VBScript access Environment variables? (https://www.kinook.com/Forum/showthread.php?t=3829)

ztron 10-19-2008 09:59 PM

Can VBScript access Environment variables?
 
I want to access environment variables such as COMPUTERNAME from within VBScript vbld_StepStarting event.

I have been using Application.Macros(vbldMacroProject)("MACRO_NAME") to access macros from within VBScripts but can you access Environment variables is a similar way?

As a work around, I have used the Set Macro step to assign an environment variable to a macro then access the macro in the script. The problem with this is the extra step and if the macro is at the project level, it modifies the project every time the bld is run.

Ron.

kinook 10-20-2008 08:15 AM

If 'Tools | Application Options | General | Include environment variables in system macros' is checked, you can use

Code:

Application.Macros(vbldMacroSystem)("ENV_VAR")
You can also access them directly from a script event. Here is a VBScript example:

Code:

Set shell = CreateObject("WScript.Shell")
Builder.LogMessage shell.ExpandEnvironmentStrings("%PATH%")



All times are GMT -5. The time now is 12:05 AM.


Copyright © 1999-2023 Kinook Software, Inc.