Currently I am using Microsoft Deployment Tools and dealing with Application deployment. It is quite a nuisance to simply copy a program to the local drive before installing. It’s actually more difficult than it sounds, as batch scripts do not like UNC paths and there is no easy path to work with if you are just running a task and not an OS install.

One thing to do is create a self extracting exe and run a script to perform everything locally from a known directory. Windows 7 and XP (and older versions) have a built in tool named iexpress. Quite a handy free tool. One problem. In Windows 7 when trying to run a script after the install it does this:

"Error creating process . Reason: The system cannot find the file specified."

Command.com?! That’s old school, and hence the problem. Windows 7 has only cmd, not command. So when you’re at the ‘Install Program to Launch’ screen and you simply put ‘install.bat’ it precedes it with ‘command /c’. Solution is to do it like this:

Update (12/10/2010): Small note, if your using this, you might prefer to move over to using Winrar from Grisoft which has a much better interface and capabilties for creating a SelF eXtracting (SFX) file!

65 Comments

  • Hey, thanks for the cmd /c tip! Been searching high and low for that to solve the create process problem.

    Thanks again!

  • I saw several examples about iexpress and nowhere talks about the cmd /c tip.
    I was lost trying to work iexpress until find your site.
    thanks

  • Thanks for the tip! It was all I actually needed.
    I have a remark – if you plan to run the .exe you create on Windows XP, do not create it with the iexpress tool of Windows 7! It won’t be backwards compatible. Instead you should create it using the iexpress provided in Windows XP. This way it will run on both XP and Win 7.

  • Thanks SwappeR, I would have never thought of that. I assumed how ugly the interface still was that it was running the same code from XP 😛

  • Hi,

    I used the batch file : MKDIR %Tmp%\
    XCOPY . %Tmp%\ /S /E /Y
    %Tmp%\\setup.exe

    from http://www.itscodingtime.com/post/Combine-Setup-MSI-and-EXE-into-a-single-package-with-IExpress.aspx

    but as soon as i hit the bundled exe, it gets closed and files in temp folder are deleted.

    I know that when setup.exe is started, it initiates msiexec.exe but i want to wait till msiexec.exe exits with some code. How do i do that ?

  • First off, use quotes for those locations. I believe a space in any one of them would cause a failure. Second, try putting a pause command at the end of the batch file, it may help show any errors you are receiving.

    Now, I’d still highly recommend using WinRar (link above in my article) for this stuff as it just allows for more adjustability and ease. But I’ll take a stab at that might work for you here using IExpress. I’m flying blind without the exe or msi but here goes:

    MKDIR “%Tmp%\kulvinder”
    XCOPY . “%Tmp%\kulvinder” /S /E /Y
    start /wait “Setup” “%Tmp%\kulvinder\setup.exe”

    To pause at the end so you can see the output, type ‘pause’ (sans-quotes) to the end of the above commands.

  • Thanks for your help but this doesnt work either.

    I removed all the lines in the bat file except the first one but it even doesnt create a folder in %Tmp% folder.

    However, if i run the bat file manually (updated one or the previous one) it does everything what it supposed to do. So, i believe the issue is only when i am executing the bat file with IExpress. Please help me on how can i get rid of these issues.

  • @Kulvinder: When creating the exe, put a Finish Message on it (through IExpress). Run it, leave it at the finished message (don’t close it, so it doesn’t clear its temporary files) and check the %tmp% directory. It should have a folder named IXP000.TMP or similar. If you don’t have this, you need to figure out why the initial files aren’t being extracted (you should really just need to make sure you packaged your files).

    If those files are there, but the batch is still not running, make sure the batch file is within the IXP000.TMP. If it is there, it would seem your install command is not correct. Your install program, within the ‘Install Program to Launch’ IExpress dialogue should be ‘cmd /c yourbatchfile.bat’ without quotes, and renaming yourbatchfile.bat to your bat file.

    If you can upload your SID file somewhere I can take a look at it.

  • I think i got the issue. Now, i only need your help to resolve it. The culprit is the .bat file command. See below :

    MKDIR “%Tmp%\kulvinder”
    XCOPY . “%Tmp%\kulvinder” /S /E /Y
    start /wait “Setup” “%Tmp%\kulvinder\setup.exe”

    I never had a “Kulvinder” folder in %tmp%. The folder being created is only IXP000.TMP

    I am surprised to see why no “Kulvinder” folder has been generated. Seems like the .bat file is not running at all. I am using Windows 7 IExpress and the install program to launch is in the same format as you have suggested. Please help

  • [Version]
    Class=IEXPRESS
    SEDVersion=3
    [Options]
    PackagePurpose=InstallApp
    ShowInstallProgramWindow=0
    HideExtractAnimation=0
    UseLongFileName=0
    InsideCompressed=0
    CAB_FixedSize=0
    CAB_ResvCodeSigning=0
    RebootMode=I
    InstallPrompt=%InstallPrompt%
    DisplayLicense=%DisplayLicense%
    FinishMessage=%FinishMessage%
    TargetName=%TargetName%
    FriendlyName=%FriendlyName%
    AppLaunched=%AppLaunched%
    PostInstallCmd=%PostInstallCmd%
    AdminQuietInstCmd=%AdminQuietInstCmd%
    UserQuietInstCmd=%UserQuietInstCmd%
    SourceFiles=SourceFiles
    [Strings]
    InstallPrompt=
    DisplayLicense=
    FinishMessage=I am done
    TargetName=E:\Code\VSTO.2010\VSTO2010AddInSetup\MyApp.exe
    FriendlyName=MyApp
    AppLaunched=cmd /c MyApp.bat
    PostInstallCmd=
    AdminQuietInstCmd=
    UserQuietInstCmd=
    FILE0=”MyApp.bat”
    FILE1=”setup.exe”
    FILE2=”MyApp.VSTO2010AddInSetup.msi”
    [SourceFiles]
    SourceFiles0=E:\Code\VSTO.2010\VSTO2010AddInSetup\
    SourceFiles1=E:\Code\VSTO.2010\VSTO2010AddInSetup\Release\
    [SourceFiles0]
    %FILE0%=
    [SourceFiles1]
    %FILE1%=
    %FILE2%=

  • I again looked at IXP000.TMP folder and the files present there have incomplete names. Could this be the problem ?

    MyApp.bat file name is MyA~1.bat

  • I reduced the name of the bat file and it worked !!

    Wow !! What an issue that was

    Please tell me how to ensure that the “kulvinder” folder is deleted when the setup.exe and .msi file execution is complete.

  • Also, the same executable doesnt work on Windows XP

  • If i use IExpress on Windows XP (2.0 version), it runs on Windows 7.

    There is still an issue. The Setup.exe looks for VSTO2010AddInSetup.msi file but that is not there since the file copied has name – VSTO~1.msi

    How do i ensure that the names of my file are not changed by the installer while copying to temporary file ?

  • @Kulvinder: The batch was being renamed because you have UseLongFileName=0. In IExpress make sure use long file names is checked. This is for backwards compatability with windows 95! As for running on XP, it should as far as I know but I never went into length to check that.

    To remove the directory, you will have to put something along the lines of ‘rd %tmp%\kulvinder /s /q’ to the end of your batch file.

  • That solved the problem.

    One Last couple of questions :

    1. I wanted to integrate this process of creating a single installer when my Windows installer project in VS 2010 is build. How do i do that ?
    2. My dev machine is on Windows 7. So, the created self extractor will not work on Windows XP ?

  • Please reply

  • Hi Kulvinder,

    1. You can use command line to package using IExpress. Run ‘iexpress /?’ in a command line to see the arguments needed. After the build process you’d simply run the command to do whatever you need to do.
    2. It appears that IExpress will run as a 64 bit program and the saved file will only work on x64 machines. Unfortunately I see no way around this. You could try importing an IExpress executable from a 32 bit Windows onto the 64 bit system.

  • I tried to use ‘iexpress’ on my Win7 64bit.
    it didn’t gave me any kind of error or warning during to creation.
    but after that the executable file does not run on 64 bit machines.

    so, is there any different command or argument for creating 64 bit compatible file??

  • See the comment above yours. You’ll either have to try (not sure if this would work) grabbing iexpress from a 32 bit computer and copying over to your x64 system (search Windows 7 directory). Otherwise, use winrar and work with the SFX options (SelF eXtracting file). Look at the bottom of the main post for the link.

  • Another way to work around the batch file issue is to rename the batch file with a “cmd” extension instead of a “bat” extension. Then there is no need to add the cmd /c command prefix, just enter .cmd as the name of the file to run.

  • I used cmd /c setup.bat in the iExpress Install Program and finish the installable preparation. But when I run it it shows a console screen and the path to my newly created temporary folder. It halts there and nothing more happens. No installation starts. What may be the problem…

  • I would break it down a bit and try without iexpress to rule out if its the problem or not. Dump your files in a folder, navigate there with cmd, and run cmd /c setup.bat and see if there is any difference.

  • Thank you for the cmd /c command, it is a big help. I have a question though, not sure if this can be accomplished with iExpress…

    Please note I am new to script/batch file writing…

    I have written a bat file that needs to rename a file located a couple levels down in a directory structure. This is for modifying a race track file inside a game installation folder. This will need to occur on multiple machines with varying drive paths so I wrote the bat file to run from the root game directory however it does not work when packaged into iExpress. There is no error, the file does not get renamed and there is no .old file showing.

    Is this due to iExpress unpacking into the temp directory?

    If so, could I tell CMD to grab the file from the users temp directory and wild card the user somehow so it works for everyone involved?

    Here is an example of the file (ran from the Game Install Directory):
    @echo off
    cd GameData\Locations\Track\Track
    rename SomeFile.doc SomeFile.doc.old
    cd..
    cd..
    cd..
    cd..
    copy NewFile.doc.new GameData\Locations\Track\Track
    cd GameData\Locations\Track\Track
    rename NewFile.doc.net NewFile.doc

    I have included NewFile.doc.new into the Packages area for iExpress along side the batch file.

    Thank you,
    JB

  • Do you see it at least running the batch file? If so, just get rid of the @echo off, and see what your batch file is doing that is causing it to fail to rename those files.

  • IExpress is pretty handy for a free included app, and I’ve used it quite a few times with XP, but ran into this issue when using it for the first time with Windows 7 (was actually surprised it was included with 7!)

    This was a great quick fix that works! Thank you very much.

  • Thanks very much for the fix Mike, I was having the same issue on our Windows 2003 Server, but only recently, and it was driving me insane!

  • where i can find that iexpress wizard

  • Simply running iexpress from start -> run will start it up. Otherwise if you are looking for exact location its in C:\Windows\System32.

  • Hi ,

    I m not able to run my shutdown.exe file. It is throwing one error like:
    Error creating process , Reason: The system cannot find the file specified. I m using Windows 7 Operating system. I have given cmd/c command in the IExpress Install Program Launch while installing the batch file. My batch file contains the following command.
    c:\windows\system32\shutdown -s.

    Can anyone help me in fixing this issue!

    Thanks

  • Hi Antara,

    I just tried this command with no troubles cmd /c c:\windows\system32\shutdown /s

  • Thanks for this hint. It worked out very well on my Windows 7 64Bit system.

    Another thing, though not related to this error.

    Is there any possibility to set a custom icon for the exe file created?

    Regards,

    Robert

  • Hi Orschiro,

    Not without third party software. Generally you can try google for ‘adding icon to exe’ and get lots of freeware (may take some digging to find reputable one however.

    I know that WinRAR (link in article) has the ability to do the same as Iexpress but with much more advanced options (including icon or logos).

    Cheers
    Mike

  • Hello Mike,

    Thanks for your quick reply!

    I found a workaround by simply creating a shortcut which can then have a custom icon.

    Regards,

    Robert

  • My post got totally screwed up for some reason. Probably non-escaping special characters?

    I found this thread very helpful when using iExpress for the first time.

    In particular:

    1) iExpress extracts your package contents to %USERPROFILE%\AppData\Local\Temp\IXP000.TMP\ it is important that you use this path in your Install Command file when referencing any other files in your package that you want to run.

    2) Once package is run, the IXP000.TMP directory should delete automatically. If you still have a previous iExpress package running when you are testing, you might run into a problem where IXP001.TMP is created as the extract folder (because the previous package hasn’t completed yet and has left IXP000.TMP present). Just something to be mindfull of if you are chasing your tail!

    3) Instead of the “cmd /c ” prefix for a BAT file, you can simply rename your install BAT file with the CMD extension and run that

    4) Unless you select the Long Filenames option in iExpress, when you create your package, the names of your extracted files will change to the old DOS ~1 filename types. This will cause issues if your install command file is referring to the original file name. Use the Long Filenames option.

    All this info relates only to running and testing iExpress on a Win7 x86 machine. I’ve not tried to backwards test on XP yet.

  • Hi OdgeUK

    Regarding #1 — Actually I would stay away from this! When running a batch file it will run relative to the directory it is in. For most things this path should never be absolute, it should all be relative.

    Good tips otherwise!

  • Mike – You’re right! I had put that path in while I was troubleshooting the Long Filenames problem. Yes, the Install Program (whether CMD or BAT) will run relative to the directory it’s in, usually %USERPROFILE%\AppData\Local\Temp\IXP000.TMP\

  • Thanks for ur post

  • Also…if you create the EXE in iExpress on a Win7x64 machine, don’t expect that your resultant EXE will work on an x86 machine! Think this was hinted at in an earlier post but have just fallen foul of it!

  • Thanks man! Really thanks!

  • You have no idea….
    How great it is to find this post

  • Thank you Mike for the tip.

    For those like me that still ignore the basics and bump into this great tip while looking for help I resolved a problem I was having by enclosing in double quotes the batch name when the name include blanks as in:

    cmd /c “copynet – Copy.bat”

    I had it without the double quotes and it wouldn’t do anything. Added the double quotes and problem solved.

    Thank you for posting this tip. Great help. Sure you can use winrar and w7zip but only if you run the network and you set your own policies as to what you can download and install on your pc 🙂

    Cheers

  • A very simple and best solution to all.. Use 7Zip and its SFX features; and it can meet all your requirements like 32/64 bit, icon to exe and so on.. I tried all and seems that 7Zip is better since it is 100% free..

  • Thanks!!!

  • Thank you very much that solved my problems

  • Hi,I have reated an exe using iepress.exe

    I have a bat file. This bat file contains adding 5 registry keys. .
    I have added this bat file in the exe using iexpress.exe and used cmd /c Registry.bat in the installation command in iexpress.exe

    I have created above exe using iexpress.exe in windows 7 64 bit. But exe is not working in Windows 7 4 bit.

    Note: if I create same exe in windows 8 using iexpress.exe works in windows 8 machine.

    I am having a tough time.. troubleshooting, why exe created using iexpress.exe is not working in windows 7 64 bit.

    If I run the bat file localy on windows 7 64 bit, it works. but exe created using iexpress.exe ot works in windows 7 64

    when I run the exe in cmd prompt with admin login in windows 7 4 bit, nothing gets executed. The cursor comes to next line. that’s it.

    Pls help me in resolving this issue at earliest.. I am struck and scratching my head like anything!!!!!!!!!

  • On 64-bit Windows 7, %WinDir%\system32\iexpress.exe is a 64-bit application that will create 64-bit executable packages. This is the version that will be executed if you just run “iexpress” or “iexpress.exe” from Start => Run… or Command Prompt. To create 32-bit executable packages, you have to specifically run %WinDir%\SysWOW64\iexpress.exe instead.

  • It works like a charm! Thanks!

  • Thanks.

    cmd /c install.bat
    is working fine
    for “error creating process command.com /c”

Pingbacks