locked
executing a bat or cmd file in a Data Tools 2012 project RRS feed

  • Question

  • I have a 2008 R2 SSIS project I'm converting to Data Tools 2012.  Part of this is command another software package via the command line using a cmd/bat file.

    However, this process seems to have changed in Data Tools 2012, since this no longer works.  How do I use an 'Execute Process Task' to execute a .bat or .cmd file?

    Thanks

    Monday, November 11, 2013 10:54 PM

Answers

  • @bhassel07,  try using C:\myPath\myCommand.cmd  where you currently have the path\cmd.exe . set your working directory to the output directory path if you have output, if not, set the directory to c:\myPath -- where c:\myPath is the directory that has your command file. Let's say you want to silently launch Photoshop.exe within in your command script -- use start  which will launch and exit photoshop:

    start "" "C:\Program Files\Adobe\Adobe Photoshop CS4\Photoshop.exe"

    You can .. in the next line, launch the next *.cmd file.

    start "" "C:\Program Files\Adobe\Adobe Photoshop CS4\Photoshop.exe"

    start "" "C:\myPath\myCommand_2.cmd param1 param2"


    • Proposed as answer by Mike Yin Friday, November 15, 2013 3:03 AM
    • Edited by plditallo Friday, November 15, 2013 3:55 PM
    • Marked as answer by Mike Yin Monday, November 18, 2013 2:32 PM
    Wednesday, November 13, 2013 1:32 AM

All replies

  • @bhassel07,

    I just tested a conversion of an ssis 2008 package with an execute process task in it which worked.  I can't speak to your specific task--but this is a very simple component. If you are interested in isolating whether any execute process task will work, try this:

    1. create a *.bat process called metroNSLookup.bat (scroll for command detail)

    2. create a new ssis 2008 package with a new execute process task component. Edit the component to include these values--let every other option default.

    Executable:  c:\yourPath_cmds\metroNSLookup.bat

    no arguments

    working directory: c:\yourPath_output

    -- executable for metroNSLookup.bat --

    @ECHO OFF &SETLOCAL
    for /L %%N in (1,1,10) do nslookup 76.72.170.%%N >>c:\SSISDev_Output\nslookup.txt 2>&1
    TYPE c:\SSISDev_Output\nslookup.txt>>c:\SSISDev_Output\nsMetroOutput.log

    3. run the ssis package in 2008.

    4.  open the package in 2012, let the package convert.

    When the task runs 2 output files will exist in your output path. If this works, post the details of your conifiguration/edits.



    • Edited by plditallo Tuesday, November 12, 2013 3:38 PM
    Tuesday, November 12, 2013 2:14 AM
  • That worked fine.  No edits other than making sure I had the directories etc setup.

    Thanks

    Tuesday, November 12, 2013 3:07 PM
  • Glad that worked. Now we know for sure that existing execute process tasks (ept) will convert properly from 2008 R2 to 2012.  Are you still having trouble with your conversion/ept?
    Tuesday, November 12, 2013 3:37 PM
  • yes.  I have 3 scripts (.cmd files - although I've tried the .bat extensions as well). In 2008R2 SSIS execute process task was just a link to the file itself.  When I execute that I receive and error message: 'The process exit code was "1" while the expected was "0".

    I tried using 'C:\windows\system32\cmd.exe' as the executable and the file path/name as an argument, but that doesn't work (no error but no results either).  The scripts when execute manually on the DOS command line work fine and I get the expected results.

    Thanks

    Tuesday, November 12, 2013 4:01 PM
  • @bhassel07,  try using C:\myPath\myCommand.cmd  where you currently have the path\cmd.exe . set your working directory to the output directory path if you have output, if not, set the directory to c:\myPath -- where c:\myPath is the directory that has your command file. Let's say you want to silently launch Photoshop.exe within in your command script -- use start  which will launch and exit photoshop:

    start "" "C:\Program Files\Adobe\Adobe Photoshop CS4\Photoshop.exe"

    You can .. in the next line, launch the next *.cmd file.

    start "" "C:\Program Files\Adobe\Adobe Photoshop CS4\Photoshop.exe"

    start "" "C:\myPath\myCommand_2.cmd param1 param2"


    • Proposed as answer by Mike Yin Friday, November 15, 2013 3:03 AM
    • Edited by plditallo Friday, November 15, 2013 3:55 PM
    • Marked as answer by Mike Yin Monday, November 18, 2013 2:32 PM
    Wednesday, November 13, 2013 1:32 AM
  • Superb! This worked for me. Thanks a ton
    Tuesday, February 5, 2019 11:15 PM