Lee posted on November 16, 2009 14:34

An easy way to add them to your system.

 

I’m beginning to use environment variables more and more these days for SSIS and find it a pain to have to keep opening the system properties to get to them.  An easy way to set, list, or delete them is by using a simple vb script such as the one below.  I spent a grand total of about two minutes drawing this one up, but it works and is a lot better than having to continue making the trek through My Computer to get to them.  Simply add this to a file, and change the extension to .vbs. Then you can set the names of yours and then double-click on it to have them written to your system. 

Lee

 

--------------------------

 

Jammin!

 

 

 

 

'

' VBScript to set environment variables

'

 

wscript.echo "Adding environment variables..."

set WshShell = CreateObject("WScript.Shell")

 

' Select the type of variable

set instEnv=WshShell.Environment("User")

 

' Name and configure your environment variables

instEnv("ETL_SERVER")                            = "SVR1"

instEnv("ETL_CONFIG_DB_SERVER")          = "SVR2"

instEnv("ETL_AUDIT_DB_SERVER")            = "SVR3"

instEnv("ETL_CONFIG_DB")                      = "DB1"

instEnv("ETL_AUDIT_DB")                        = "DB2"

instEnv("ETL_PKG_FILE_SHARE")               = "C:\TEMP"

 

' Use the following to remove user environment variables

'instEnv.Remove "ETL_SERVER"

 

' List all vars in all environment types

wscript.echo "Listing environment variables"

set instEnv=WshShell.Environment("User")

 

for each sitem in instEnv

          if (left(sitem,3))= "ETL" then

                   strval=strval & sItem &vbcrlf

          end if

next

 

wscript.echo "Environment Variable Listing:"&vbcrlf&vbcrlf&strval

strval=""

 

set instEnv = nothing

 

 


blog comments powered by Disqus

by Lee Everest, M.S.

Poll

Do you use Azure or cloud in your organization?



Show Results

Ads

Search


Month List

Calendar

«  February 2012  »
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011
View posts in large calendar

Tags

Disclaimer
The opinions, code, examples, et.al. expressed herein are my own personal opinions and do not represent my employer's view in any way, shape form, or fashion.  All code for demonstration purposes - no guarantees, either written or implied, are made.

© Copyright 2012 Lee Everest's SQL Server, etc. weblog