How to get Application path in Integration Services Package?
We have a main package which is calling multiple other packages. The the child packages uses parent package variables and which we are configuring using configuration file while installation of the package. Here we need to set each path while installation because there are many variables using the same path with the different file names(Different files stored in same Folder). We want to get the main path and then if we use relative path in other variables then we need not to assign all the variable paths while installation.How to we can get the Application path in Integration Services Package(Script Task)?Thanks in Advance!
April 13th, 2007 9:59am

SSIS doesn't support relative paths, and there isn't a concept of an "application path". This makes sense if you consider that packages can be developed and executed in memory, or stored in a database, where the package never exists in the file system.The best I've been able to do is define a relative path from an absolute "root" location that can be read dynamically, such as the USERPROFILE environment variable. I'd use an expression to combine the dynamic root location and my hard-coded relative path and assign them to whatever object I was trying to configure (execute package task, file source/destination, etc.)This still requires some degree of conformity (so it isn't truly relative) since each user will either have to use the same package location inside their USERPROFILE, or each environment will have to define its own "root" path.Hope that helps.
Free Windows Admin Tool Kit Click here and download it now
April 13th, 2007 2:55pm

You can use a relative path like ".\MyPackage.dtsx", where the . evaluates to the current working directory. However, I strongly recommend that you do not do this. The working directory ina Windows environment can be affected by a number of things (like whether you open the solution file or the project file in Visual Studio), so you can get some unpredictable results unless you understand how Windows handles the current directory concept. The better way is what Jay described. Use expressions to create your paths by passing a root directory into the package using a configuration or a /SET, and concatenate that with the relative location.
April 13th, 2007 4:51pm

Thanks for your answer.We are using the same way as you have mentioned.In our application we have a main package and which calls few other packages and we have one variable which defines the root path. We are setting other package paths using the Root path variable using Script Task in the main package task.But we were thinking as if SSIS gives the facility to get the application installed path then we need not to assign the root path variable also.I heard from somebody as it is possible to get an application path but how that I don't know.For now workaround is to use variable and that should be set while installation.
Free Windows Admin Tool Kit Click here and download it now
April 16th, 2007 11:38am

It's not possible to get thepackage path from inside an SSIS package. Specifying a root path is the way to go.
December 20th, 2007 9:46pm

How about trying a really dirty hack?Create a variable in the package (i.e. CurrentPath)Set the "ReadWriteVariables" of the ScriptTask to the variable's name.Create a console app with just these lines of code. class Program { static void Main(string[] args) { string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; Console.Write(path); } }Copy the exe to the path of your package.In your ScriptTasks's code write Dim p As New System.Diagnostics.Process With p.StartInfo .FileName = "PathGetter.exe" .UseShellExecute = False .CreateNoWindow = True .RedirectStandardOutput = True End With p.Start() p.WaitForExit() Dts.Variables("CurrentPath").Value = p.StandardOutput.ReadToEnd().TrimEnd("\"c)Done.
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2008 3:10am

Drapondur, I tried your method and I still unable to get the SSIS startup path. 1 ) the PathGetter.exe will not execute in the SSIS foleder because the parent package unable to locate the PathGetter.exe 2 ) I copied it to C:\Windows\ so any app can run like notepad. The SSIS call to PathGetter.exe and get C:\Windows as return result.
August 12th, 2011 9:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics