Is is possible to read system environment variables in a Windows Scripting Host (WSH) VBS script?
(I am writing a VBScript using Windows Scripting Host for task for a Cruise Control and want to pick up the project build URL.)
Right click the Computer icon on your desktop and choose Properties from the menu. Click on the Advanced system settings link and then click Environment Variables. Under the section System Variables, select the environment variable you want to edit, and click Edit.
The ExpandEnvironmentStrings method expands the environment variables in a string and returns the resulting string. Environment variables are case-insensitive and are enclosed by a pair of % characters. If an environment variable in strString is undefined, then it is left unchanged.
Environment Script Plugin allows you to have a script run after SCM checkout, before the build. If the script fails (exit code isn't zero), the build is marked as failed. Any output on standard out is parsed as environment variables that are applied to the build.
Here's an example (taken from here):
Set oShell = CreateObject( "WScript.Shell" ) user=oShell.ExpandEnvironmentStrings("%UserName%") comp=oShell.ExpandEnvironmentStrings("%ComputerName%") WScript.Echo user & " " & comp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With