Iterate through file and Execute
Hello!
I want to iterate through .EXE files and execute it using SSIS package. So, I have used foreach loop container and drag execute process task in it. and configure them as below:
foreach loop container :
Collection Tab:
Enumerator - foreach file enumerator
Folder - C:\Users\Sample
Files: *.exe (Sample folder contains three .exe files)
Retrieve file type- Fully qualified
Variable Mapping:
Create the new variable named "myVar", scope "Package", Datatype "string", Value "1" (variable to store the path for .exe file)
Execute Process Task :
Expression tab - I went to Property expression and select "Executables" as property and and expression as @[User::myVar].
When I evaluate expression it gives me value 1.
Now , when I try to execute the package it gives me the following validation error.
TITLE: Package Validation Error
------------------------------
Package Validation Error
------------------------------
ADDITIONAL INFORMATION:
Error at Execute Process Task [Execute Process Task]: File/Process "1" is not in path.
Error at Execute Process Task: There were errors during task validation.
So, what would be the problem? can anyone please explain me. How can i iterate through multiple .exe file and execute it in SSIS?
Thanks,
November 18th, 2010 12:54pm
In the ForEach loop container, you need to map the full path of each file that this task iterates through to the variable named @[User::myVar]. This way, every time the loop picks up a new .exe file (with fullyQualified path of it) and
assigns it to the variable. And when the Execute Process task executes, it takes that file path at run time and executes a different .exe for every iteration of the ForEach loop container.
Hope this helps.
Cheers!!
Muqadder.
Free Windows Admin Tool Kit Click here and download it now
November 18th, 2010 1:02pm
you should set DEFAULT VALID PATH as default value for myVar variable. this is only for package validation.http://www.rad.pasfu.com
November 18th, 2010 1:18pm
To clarify further, you need to double click on the FOrEach loop container, go to "Variable Mappings" tab in the window that pops up and choose the @[User::myVar] from the dropdown available under "Variable" column in the tab. SSIS will map it to Index0.
which is correct. Now, go to the "Collection" tab and make sure you have selected the "Fully Qualified" radio button. Finally, check that Expression on "Executable" property of the ExecuteProcess task is set to @[User::myVar].
That should do it for you.
Hpe this helps.
Cheers!!
Muqadder.
Free Windows Admin Tool Kit Click here and download it now
November 18th, 2010 1:50pm
Hi Muqaddar,
That's what exactly I have done but It gives me the same error. I don;t know what's wrong with it.
THanks,
November 18th, 2010 2:05pm
According to your post,
Variable Mapping:
Create the new variable named "myVar", scope "Package", Datatype "string", Value "1" (variable to store the path for .exe file)
So you are harcoding the value of "myVar" to 1 for every iteration of the ForEach loop. Hence every time the lop container runs, it picks this "1" as the value and passes it on to the "Executables" property of the Execute process task.
Instead, you need to assign the dynamic path of the files the ForEach loop container iterates through and assign it to "myVar" variable. To do so, you need to double click on the FOrEach loop container, go to "Variable Mappings" tab in the window that pops
up and choose the @[User::myVar] from the dropdown available under "Variable" column in the tab. SSIS will map it to Index0.
Can yo check you have done this too??
Cheers!!
Muqadder.
Free Windows Admin Tool Kit Click here and download it now
November 18th, 2010 2:11pm
Muqaddar,
Let me tell you one more thing. In execute process task, I have set the expression on 'Executable' property of the Execute process task to @[User::myVar]. Then when I try to click ok It gives me warning that 'an executable file is not specified.' So,
I went to Process tab in Execute process task editor and set the Executable to "C:\Users\Sample\filename.exe". without doing that it doesn't do anything when I click on OK button.
THanks,
November 18th, 2010 2:12pm
According to your post,
Variable Mapping:
Create the new variable named "myVar", scope "Package", Datatype "string", Value "1" (variable to store the path for .exe file)
So you are harcoding the value of "myVar" to 1 for every iteration of the ForEach loop. Hence every time the lop container runs, it picks this "1" as the value and passes it on to the "Executables" property of the Execute
process task.
Instead, you need to assign the dynamic path of the files the ForEach loop container iterates through and assign it to "myVar" variable. To do so, you need to double click on the FOrEach loop container, go to "Variable Mappings" tab in
the window that pops up and choose the @[User::myVar] from the dropdown available under "Variable" column in the tab. SSIS will map it to Index0.
Can yo check you have done this too??
Cheers!!
Muqadder.
Yes Muqqadar, that's waht exactly i HAVE DONE.
Free Windows Admin Tool Kit Click here and download it now
November 18th, 2010 2:14pm
According to your post,
Variable Mapping:
Create the new variable named "myVar", scope "Package", Datatype "string", Value "1" (variable to store the path for .exe file)
So you are harcoding the value of "myVar" to 1 for every iteration of the ForEach loop. Hence every time the lop container runs, it picks this "1" as the value and passes it on to the "Executables" property of the Execute
process task.
Instead, you need to assign the dynamic path of the files the ForEach loop container iterates through and assign it to "myVar" variable. To do so, you need to double click on the FOrEach loop container, go to "Variable Mappings" tab in
the window that pops up and choose the @[User::myVar] from the dropdown available under "Variable" column in the tab. SSIS will map it to Index0.
Can yo check you have done this too??
Cheers!!
Muqadder.
Yes Muqqadar, that's waht exactly i HAVE DONE.
Did you EVER tried my suggestion? set a default valid full file path for myVar variablehttp://www.rad.pasfu.com
November 18th, 2010 2:23pm
hi Raad,
I tried to set valid full path (C:\Users\sample\) for myVar vairable (set the "value" field in myVar variable.). But it doesn't work,
Thanks,
Free Windows Admin Tool Kit Click here and download it now
November 18th, 2010 3:40pm
hi Raad,
I tried to set valid full path (C:\Users\sample\) for myVar vairable (set the "value" field in myVar variable.). But it doesn't work,
Thanks,
this should be full FILE PATH, like : c:\users\sample\file.exe
this file in this path should exactly existshttp://www.rad.pasfu.com
November 18th, 2010 5:06pm
This is correct. Even though the ExecuteProcess task is going to get the path of Executable at run time via the ForEach loop container, it also needs a valid path at design time, pointing to an exeecutable that must exist already. Otherwise, the task
will fail during validation phase itself. Just fot that purpose, you can set the value of the Executable property (design time) to notepad.exe (doesn't need a full path).
Check if this resolves your issue.
Hope this helps.
Cheers!!
Muqadder.
Free Windows Admin Tool Kit Click here and download it now
November 18th, 2010 6:07pm
Hello,
What about Setting Delay Validation Property= True for the Task? That way it will not care about variable value(full path or Not)
Thanks
November 18th, 2010 6:43pm