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

 

 


Comments


November 20. 2009 20:30
Pingback from trevoro.com

Lee Everest's SQL Server, etc. weblog | Adding Environment …

http://trevoro.com/lee-everests-sql-server-etc-weblog-adding-environment/http://trevoro.com/lee-everests-sql-server-etc-weblog-adding-environment/


November 20. 2009 21:58
Pingback from educemea.com

Lee Everest's SQL Server, etc. weblog | Adding Environment …

http://www.educemea.com/lee-everests-sql-server-etc-weblog-adding-environment/http://www.educemea.com/lee-everests-sql-server-etc-weblog-adding-environment/


November 21. 2009 06:31
Adding Environment Variables for SSIS

You've been kicked (a good thing) - Trackback from DotNetKicks.com

http://www.dotnetkicks.com/database/Adding_Environment_Variables_for_SSIShttp://www.dotnetkicks.com/database/Adding_Environment_Variables_for_SSIS


United States Mike
December 21. 2009 15:29
I have been doing the same thing lately.  It makes SSIS packages more portable from dev to test to production.  I found and manipulated a script to do the same thing when I had to migrate ten packages.  Doing it by hand is the worst! Smile

no site

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading




by Lee Everest, M.S.

Search


Ads

Calendar

«  July 2010  »
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
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 2010 Lee Everest's SQL Server, etc. weblog