{"id":1057,"date":"2010-01-29T09:31:39","date_gmt":"2010-01-29T09:31:39","guid":{"rendered":"http:\/\/www.mjtnet.com\/blog\/?p=1057"},"modified":"2010-01-29T20:02:43","modified_gmt":"2010-01-29T20:02:43","slug":"running-macro-scheduler-macros-over-the-web-via-php","status":"publish","type":"post","link":"https:\/\/www.mjtnet.com\/blog\/2010\/01\/29\/running-macro-scheduler-macros-over-the-web-via-php\/","title":{"rendered":"Running Macro Scheduler Macros over the Web Via PHP"},"content":{"rendered":"<p>Here&#8217;s a quick and simple proof of concept for running Macro Scheduler macros via the web and having their output displayed in the user&#8217;s browser:<\/p>\n<div id=\"attachment_1058\" style=\"width: 470px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.mjtnet.com\/images\/wamp_msched.jpg\"><img aria-describedby=\"caption-attachment-1058\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1058 \" title=\"Running Macro Scheduler Macros Over the Web Via PHP\" src=\"\/\/www.mjtnet.com\/blog\/wp-content\/uploads\/2010\/01\/wamp_msched_small.jpg\" alt=\"Running Macro Scheduler Macros Over the Web Via PHP\" width=\"460\" height=\"327\" border=\"0\" srcset=\"https:\/\/www.mjtnet.com\/blog\/wp-content\/uploads\/2010\/01\/wamp_msched_small.jpg 460w, https:\/\/www.mjtnet.com\/blog\/wp-content\/uploads\/2010\/01\/wamp_msched_small-300x213.jpg 300w\" sizes=\"(max-width: 460px) 100vw, 460px\" \/><\/a><p id=\"caption-attachment-1058\" class=\"wp-caption-text\">The screenshot shows the PHP script, Macro Scheduler script and Internet Explorer being used to run the macro.<\/p><\/div>\n<p>1) If you don&#8217;t already have a Windows based web server with PHP running, download and install <a href=\"http:\/\/www.wampserver.com\/\">WAMPServer<\/a>. It&#8217;s easy.<\/p>\n<p>2) Create a simple PHP script which takes an EXE name as a parameter and any parameters you want to pass to it.  The following script will run EXEs that are in the c:\\wamp\\ folder, passing in any parameters provided and will dispay the EXEs output.<\/p>\n<pre name=\"code\" class=\"php\">\r\n&lt;?php\r\n$exe = $_GET['exe'];\r\n\r\n$dir = \"c:\\\\wamp\\\\\";\r\n\r\n$parms = \"\";\r\nforeach($_GET as $key=&gt;$val) {\r\n  $parms .= \"\/$key=$val \";\r\n}\r\n\r\necho shell_exec(\"\\\"$dir$exe\\\" $parms\");\r\n?&gt;\r\n<\/pre>\n<p>3) PHP&#8217;s safemode must be disabled for this script to work.<\/p>\n<p>4) Create a Macro Scheduler macro and use SOWrite or SOWriteLn to output information.  Compile it with the &#8220;Create Console App&#8221; option checked.  Compile the EXE (or copy it) to the c:\\wamp\\ folder.<\/p>\n<p>5) Now the macro can be executed via the web using http:\/\/servername\/runmacro.php?exe=my.exe&amp;parm1=value&amp;etc=&#8230; which could be a link or entered into the browser directly.<\/p>\n<p>6) Consider adding further security to the script to prevent anyone running any EXE on your server, or putting it in a password protected folder.  I&#8217;ll leave that to you.<\/p>\n<p><a href=\"http:\/\/www.mjtnet.com\/macro_scheduler_enterprise.htm\">Macro Scheduler Enterprise<\/a> comes with the msNet Remote Controller which includes a CGI module for running Macro Scheduler macros via web servers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a quick and simple proof of concept for running Macro Scheduler macros via the web and having their output displayed in the user&#8217;s browser: 1) If you don&#8217;t already have a Windows based web server with PHP running, download and install WAMPServer. It&#8217;s easy. 2) Create a simple PHP script which takes an EXE [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,5,6,11],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1057"}],"collection":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/comments?post=1057"}],"version-history":[{"count":21,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1057\/revisions"}],"predecessor-version":[{"id":1080,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1057\/revisions\/1080"}],"wp:attachment":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/media?parent=1057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/categories?post=1057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/tags?post=1057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}