« Distributing small Java applications (i.e. convert to EXE) | Home | Light build of Mozilla Firefox »
Launch non-exe extension files as executables
By admin | May 1, 2011
Windows does not come with a built-in way of launching executables that are without the exe extension. However, we have written a small tool called “anylaunch” which allows one to execute any file as if it were an executable. (Non-PE files will still give an error since they are not executables “XYZ is not a valid Win32 application”)
Download (anylaunch.exe) or compile from source below:
#include <iostream> #include <windows.h> #include <cstdlib> //#define ZeroMemory(p,size) memset((p),0,(size)) using namespace std; int main(int argc, char* argv[]) { if(argc-1 < 1) { cout << "No process specified" << endl; return 0; } STARTUPINFO si; PROCESS_INFORMATION pi; // must blank it memset(&si,0,sizeof(si)); si.cb = sizeof(si); si.lpReserved = NULL; si.lpTitle = NULL; // required for GUI app si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_MINIMIZE; bool res = CreateProcess(NULL,argv[1],NULL,NULL,FALSE,0,NULL,NULL,&si,&pi); if(res == false) { printf("CreateProcess failed (error code %d)\n", GetLastError()); return 1; } CloseHandle(pi.hProcess); CloseHandle(pi.hThread); return 0; }
Download or compile the anylaunch executable and put it into the same directory as your script or into the system directory. You can use it in a command line, batch scripting or another program like so:
anylaunch “<process command line here>”
Simple examples (assuming anylaunch is in system path or current folder):
- Launching global executable
anylaunch explorer
- Launch executable in specific path
anylaunch "C:\\Tools\\wget.exe http://example.com"
Although the biggest use of this tool is to launch non-exe PE files, like so:
file yes.123
yes.123: PE32 executable for MS Windows (GUI) Intel 80386 32-bit
Then we can use anylaunch to launch this PE file:
anylaunch yes.123
You may run into some problems while running this. If your command line arguments to your target application are not showing up, you should put your entire command line into one argument and escaping quotes (anylaunch “C:\\Program Files\\Mozilla Firefox\\firefox.exe” not anylaunch C:\Program Files\Mozilla Firefox\firefox.exe). Some other common problems:
Accessing a file that does not exist or is inaccessible (The system cannot find the file specified.):
cat somefile.rnd
cat: somefile.rnd: No such file or directory
anylaunch somefile.rnd
CreateProcess failed (error code 2)
Trying to run an invalid Windows application
file Untitled.png
Untitled.png: PNG image, 800 x 600, 8-bit/color RGB, non-interlaced
anylaunch.exe Untitled.png
CreateProcess failed (error code 11) (An attempt was made to load a program with an incorrect format.)
CreateProcess failed (error code 193) (%1 is not a valid Win32 application.)
etc… (invalid format error, or win32 errors, etc)
If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!
Topics: Windows | 5 Comments »
March 28th, 2013 at 00:24
Thank you for this utility. I’m using it as one component in replacing Notepad with Notepad++(http://notepad-plus-plus.org/) without making any changes to extensions or Notepad itself.
November 4th, 2024 at 18:27
… [Trackback]
[…] Find More on that Topic: compdigitec.com/labs/2011/05/01/launch-non-exe-extension-files-as-executables/ […]
November 27th, 2024 at 22:40
… [Trackback]
[…] Info to that Topic: compdigitec.com/labs/2011/05/01/launch-non-exe-extension-files-as-executables/ […]
December 15th, 2024 at 22:31
… [Trackback]
[…] Info to that Topic: compdigitec.com/labs/2011/05/01/launch-non-exe-extension-files-as-executables/ […]
December 16th, 2024 at 21:37
… [Trackback]
[…] Read More to that Topic: compdigitec.com/labs/2011/05/01/launch-non-exe-extension-files-as-executables/ […]