tork-a / openrtm_tutorial

Compilation of existing OpenRTM tutorial contents, with some extra features that allow you to run all tutorials via InternetExplorer. Project funded by New Energy and Industrial Technology Development Organization (NEDO).
5 stars 8 forks source link

Run *.bat files via html links #5

Closed 130s closed 10 years ago

130s commented 10 years ago

In the tutorials users often need to run many .bat files from a local folder, which turned out to be requiring attention to choose the right file. So the additional requirement for the project was added to enable users to run .bat from html by just clicking links.

I just verified that this works on IE, but does not on Firefox. http://stackoverflow.com/a/18981127/577001

Plus, relative path might not work on either browser, which can also be a non-trivial issue.

130s commented 10 years ago

Using WshShell also works under the same condition mentioned in my earlier post.

130s commented 10 years ago

To sum up the research result so far:

Hereby I suggest workaround plan:

a. Only target IE, using absolute path of .bat.

b. Download .bat files via html link and run manually.

130s commented 10 years ago

https://github.com/tork-a/openrtm_tutorial/commit/863a0ae0b6f25fbc15ae9da2d0a019ebba8152e7 implements the workaround b in the earlier comment. Actually when you're downloading a .bat file, common browsers give you an option to run the file, which might suffice the purpose originally asked.

130s commented 10 years ago

Tested from the data copied on USB with https://github.com/tork-a/openrtm_tutorial/commit/863a0ae0b6f25fbc15ae9da2d0a019ebba8152e7, turned out neither Firefox nor IE don't work with it:

This result adds even more complication to the options a and b mentioned in this comment and none of them would probably not work. Unless I'd tweak by like javascript to manipulate paths, there won't be a nice resoltion that work for major browsers in any way.

sugarsweetrobotics commented 10 years ago

どうも.菅です. batファイルが実行できない件ですが,Windows + IEのみで実行できればいいです. 相対パスから実行するためのJavascriptを書きました.ActiveX使いますが・・・

<script LANGUAGE="JavaScript">
  function rtm_naming() {
    var objFileSys = new ActiveXObject("Scripting.FileSystemObject");
    var objFile = objFileSys.GetFile(location.pathname.slice(1));
    var path = objFile.ParentFolder + "\\..\\demo\\rtm-naming.bat";
    var obj = new ActiveXObject("WScript.Shell");
    obj.Run("cmd.exe /c \"start " + path + "\"");
  }
</script>

あとは,

<a class="reference external"  href="javascript:void(0)" onclick="rtm_naming(); return false;">rtm-naming.bat</a>

のように配置すれば動作します.

130s commented 10 years ago

@sugarsweetrobotics thank you for the idea but does this work on your machine?

I got rtm-naming.bat running but it fails to find omniNames. PATH seems to be set as expected but I suspect that the cmd opens at my desktop (C:\Users\myuser\Desktop) while omniNames is located under F:\misc\OpenRTM-aist\1.1.\omniORB\4.1.5\bin\x86_win32\; eg. changing the last line of the given javascript like this:

  obj.Run("cmd.exe /c \"cd .. && start " + path + "\"");

would open a terminal and prompt stays at C:\Users\myuser, backing up a folder by cd.

Thus rtm-naming.bat might be failing since it cannot find omniNames in relative path.

130s commented 10 years ago

Should be fixed via https://github.com/tork-a/openrtm_tutorial/pull/9. Now I'm testing with USB device

coded9 commented 8 years ago

So it can't be made to run on chrome ?

130s commented 8 years ago

@coded9 you're right at the moment; IE is required (as noted in readme as well) to run the pre-defined scripts from the web browser. But you can always run them from commandline (it's just you can't run them by clicking the links on the web browser except for IE).