{"id":221,"date":"2011-05-01T19:07:39","date_gmt":"2011-05-02T00:07:39","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=221"},"modified":"2011-05-01T19:07:39","modified_gmt":"2011-05-02T00:07:39","slug":"launch-non-exe-extension-files-as-executables","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2011\/05\/01\/launch-non-exe-extension-files-as-executables\/","title":{"rendered":"Launch non-exe extension files as executables"},"content":{"rendered":"<p>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 &#8220;anylaunch&#8221; 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 &#8220;XYZ is not a valid Win32 application&#8221;)<\/p>\n<p>Download (<a href=\"\/labs\/files\/anylaunch.exe\">anylaunch.exe<\/a>) or compile from source below:<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;iostream&gt;\r\n#include &lt;windows.h&gt;\r\n#include &lt;cstdlib&gt;\r\n\/\/#define ZeroMemory(p,size) memset((p),0,(size))\r\nusing namespace std;\r\n\r\nint main(int argc, char* argv[])\r\n{\r\n\tif(argc-1 &lt; 1) {\r\n\t\tcout &lt;&lt; &quot;No process specified&quot; &lt;&lt; endl;\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tSTARTUPINFO si;\r\n\tPROCESS_INFORMATION pi;\r\n\t\/\/ must blank it\r\n\tmemset(&amp;si,0,sizeof(si));\r\n\tsi.cb = sizeof(si);\r\n\tsi.lpReserved = NULL;\r\n\tsi.lpTitle = NULL;\r\n\t\/\/ required for GUI app\r\n\tsi.dwFlags = STARTF_USESHOWWINDOW;\r\n\tsi.wShowWindow = SW_MINIMIZE;\r\n\t\r\n\tbool res = CreateProcess(NULL,argv[1],NULL,NULL,FALSE,0,NULL,NULL,&amp;si,&amp;pi);\r\n\tif(res == false) {\r\n\t\tprintf(&quot;CreateProcess failed (error code %d)\\n&quot;, GetLastError());\r\n\t\treturn 1;\r\n\t}\r\n\r\n\tCloseHandle(pi.hProcess);\r\n\tCloseHandle(pi.hThread);\t\r\n\treturn 0;\r\n}\r\n<\/pre>\n<p>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:<br \/>\n<b>anylaunch &#8220;&lt;process command line here&gt;&#8221;<\/b><\/p>\n<p><b>Simple examples (assuming anylaunch is in system path or current folder):<\/b><\/p>\n<ul>\n<li>Launching global executable\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">anylaunch explorer<\/pre>\n<\/li>\n<li>Launch executable in specific path\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">anylaunch &quot;C:\\\\Tools\\\\wget.exe http:\/\/example.com&quot;<\/pre>\n<\/li>\n<\/ul>\n<p>Although the biggest use of this tool is to launch non-exe PE files, like so:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">file yes.123<\/pre>\n<p>yes.123: PE32 executable for MS Windows (GUI) Intel 80386 32-bit<br \/>\nThen we can use anylaunch to launch this PE file:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">anylaunch yes.123<\/pre>\n<div id=\"attachment_222\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.compdigitec.com\/labs\/wp-content\/uploads\/2011\/05\/process.png\"><img aria-describedby=\"caption-attachment-222\" decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.compdigitec.com\/labs\/wp-content\/uploads\/2011\/05\/process.png\" alt=\"Non-exe process in Task Manager\" title=\"Non-exe process in Task Manager\" width=\"400\" height=\"300\" class=\"size-full wp-image-222\" \/><\/a><p id=\"caption-attachment-222\" class=\"wp-caption-text\">Non-exe process in Task Manager<\/p><\/div>\n<p>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 (<b>anylaunch &#8220;C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe&#8221;<\/b> not <span style=\"text-decoration: line-through;\"><b>anylaunch C:\\Program Files\\Mozilla Firefox\\firefox.exe<\/b><\/span>). Some other common problems:<\/p>\n<p>Accessing a file that does not exist or is inaccessible (The system cannot find the file specified.):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">cat somefile.rnd<\/pre>\n<p>cat: somefile.rnd: No such file or directory<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">anylaunch somefile.rnd<\/pre>\n<p>CreateProcess failed (error code 2)<\/p>\n<p>Trying to run an invalid Windows application<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">file Untitled.png<\/pre>\n<p>Untitled.png: PNG image, 800 x 600, 8-bit\/color RGB, non-interlaced<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">anylaunch.exe Untitled.png<\/pre>\n<p>CreateProcess failed (error code 11) (An attempt was made to load a program with an incorrect format.)<br \/>\nCreateProcess failed (error code 193) (%1 is not a valid Win32 application.)<br \/>\n<em>etc&#8230; (invalid format error, or win32 errors, etc)<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>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 &#8220;anylaunch&#8221; 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 &#8220;XYZ is not a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/221"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=221"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/221\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}