SCCM 2007 - Convert BAT File to EXE or CMD RRS feed

  • Question

  • I am trying to convert a bat or cmd file to an EXE or MSI file. I have tried IEXPRESS but there is a problem occuring when the file runs. Are there other free utilities from Microsoft for doing this or are there other reliable suppliers of free software to do this?

    The error by the way is:

    "The operating system reported error -2147024894"  Failed (Bad Environment)

    Is there a tutorial document on running CMD or BAT files in SCCM?

    Thanks in advance for any replies.

    Thursday, March 15, 2012 4:57 PM


All replies

  • Hi,

    Are you deploying the .BAT or .CMD file with SCCM? You can run it without converting it, how the syntax should look like depends on what you want to achieve.

    If you are trying to copy file from the package you need to handle that using %~dp0 in the CMD or BAT file like described in the post below.



    -- My System Center blog ccmexec.com -- Twitter @ccmexec

    Thursday, March 15, 2012 6:53 PM
  • Can you please let us know what your end goal is and why you are trying to do this? As Jorgen stated, there is no ConfigMgr centric reason for doing this as it will run batch files fine.

    Also note that tools like IEXpress don't convert batch files, they simply encapsulate them creating a self-extracting executable.

    Jason | http://blog.configmgrftw.com | Twitter @JasonSandys

    Thursday, March 15, 2012 9:30 PM
  • I have successfully used 'Bat to Exe converter' in the past...

    My Microsoft Core Infrastructure & Systems Management blog - blog.danovich.com.au

    • Proposed as answer by danovich_ Friday, March 16, 2012 12:00 AM
    Friday, March 16, 2012 12:00 AM
  • At the moment I am just trying to make any cmd or bat file run. There is one line in the current test file

    dir > c:\temp\out.txt

    It works if I run it myself but it does not work if I run it using SCCM.

    I have installed software using EXE and MSI files.

    Friday, March 16, 2012 9:42 AM
  • I got the problem above fixed by deleting the Package and Advertisement. I then recreated them and the file worked.

    Now my problem is that I want to add a key in the registry called TEST. I have amended the batch file and it now contains one line

    regedit.exe /s addtestkey.reg

    The c:\windows\system32\ccm\cache\NUMBER folder contains install.bat, regedit.exe and addtestkey.reg and the advertisement report says "Program completed with success" but the registry key is not added.

    The program is set to run with administrative rights.

    Does anyone have a suggestion as to why this key is not being added to the registry? 

    Friday, March 16, 2012 11:03 AM
  • I change the Program so that the Command Line read regedit.exe /s addtestkey.reg and the registry key was created. So what is wrong with my BAT file?

    Friday, March 16, 2012 11:14 AM
  • It might be possible that the batch was not able to find the reg file. Which return code was returned? See execmgr.log. See http://blogs.catapultsystems.com/jsandys/archive/2009/08/30/current-directory-in-configmgr-programs.aspx on how to use %~dp0 in bat/cmd files.

    Torsten Meringer | http://www.mssccmfaq.de

    • Marked as answer by Micknet Thursday, March 29, 2012 2:44 PM
    Friday, March 16, 2012 11:28 AM
  • Thank you. %~dp0 is the answer.
    Thursday, March 29, 2012 2:44 PM