Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I pick up environment variables in vbscript WSH script?

Tags:

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.)

like image 698
mike nelson Avatar asked May 24 '09 21:05

mike nelson


People also ask

How do I select an environment variable?

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.

What is ExpandEnvironmentStrings?

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.

What is an environment script?

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.


1 Answers

Here's an example (taken from here):

Set oShell = CreateObject( "WScript.Shell" ) user=oShell.ExpandEnvironmentStrings("%UserName%") comp=oShell.ExpandEnvironmentStrings("%ComputerName%") WScript.Echo user & " " & comp 
like image 164
M4N Avatar answered Oct 16 '22 03:10

M4N