ShellExec (a tiny tool)

Download ShellExec (source code)

Here's a really simple but surprisingly useful little tool.  It performs a shell execution of a command.  That's it.  Some applications only allow you to specify an executable to run as opposed to a file or URL.  This is because they spin up a new process from the executable instead of using the shell to execute the command.  This tool bridges the gap.  You can call it as an executable and it runs the command line arguments as a shell command.

Start-Run vs cmd.exe

When running something from Start -> Run (Win-R key) a shell execution is performed, so links or files open fine.  cmd.exe does not use shell execution, so if you wanted to open a file or URL from the command line, you'd have to know the application assigned to handle the file/URL, or use a shell execution (like ShellExec myfile.txt)  BTW, 4NT does perform shell executions at the command line.

CD Autorun Example

Another example is the autorun.ini file for a CD.  Say you want to launch a .hta, .html, .txt, or URL?  You can't directly because an executable is required.  Here's a sample Autorun.ini that opens Setup.html when the CD is inserted (assuming ShellExec.exe is in the root directory w/ setup.html)


open=ShellExec setup.html


Usage Syntax

ShellExec [/ec|/ea] <cmd> [<args>]
ShellExec /c
ShellExec /?
ShellExec /about


/ec Expand environment variables on the command only
/ea Expand environment variables on the entire line (command and arguments)
<cmd>  The command to be run with the shell
<args>   Arguments to be passed to the command
/? Show the usage syntax
/c Run what's in the clipboard.
/about Show this web page.


  • Want to launch a file using the shell's associated application?
    ShellExec MoreInfo.txt
  • Need environment variable expansion in an app that doesn't support it?
    ShellExec /ec "%windir%\notepad.exe"
  • How about running a URL?
    ShellExec " Hockey Monkey.mp3"
Comments (8)

  1. Couldn’t you use "cmd.exe /c start [file]"?

  2. noahc says:

    Excellent point.  I don’t see why not!
    The only difference I see is that since cmd.exe is a console application, you’ll get this little console pop up real quick instead of a seamless, transparent operation with ShellExec since it is a win app.

  3. Max Battcher says:

    I certainly use the ‘start’ command often in cmd.exe windows.  Much faster than copying and pasting stuff into the Run dialog box.

    I’m still surprised sometimes that people don’t realize ‘start’ is available (much less has been around since Win95).  I can’t tell you how many times I’ve used some command line tool to generate some output (a .png, for example) and it was so much easier to ‘start out.png’ then to open a folder window and navigate and double click on that one file…

    This ShellExec may be very useful for those rare consoles that don’t have ‘start’, though…

  4. Mike Whyte says:


    Came across this app today for the first time. Tried executing ShellExec.exe on Windows XP (SP2), but got the error "application failed to initialize properly". Why is this?



  5. Eric says:

    does this require the .net framework be installed?

  6. David Evans says:

    could you comment on the min OS requirements for this tool? does .net 2.0 need to be installed as earlier remarked?

  7. Reginald Kinnaman says:

    I’m just not having any luck getting an html to run in my autorun.inf file, I have tried this utility shellexec and also shellexe and shellexecute.

    the first example has the menu for some of my games in a subdirectory, the other two example show i put it in the root directory. All 3 examples work on Vista. None work on Windows xp Professional and Windows XP Home (i have 4 other computers for testing) Ive spend more time on this autorun issue than making the html (which has been alot of time now) if some one has any other ideas as to what is wrong on the computers, please let me know.




    open=ShellExec.exe INSTALL.HTML


    open=ShellExe.exe INSTALL.HTML

  8. Michael says:

    I think it should be noted it is more like:

    cmd /c start /D"<drive>:FullPathofFile" foobar.html


    cmd /c start "" "<drive>:FullPathofFilefoobar.html"

Skip to main content