从android执行.bat文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10561729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:10:35  来源:igfitidea点击:

execute .bat file from android

androidbatch-filevideo-encoding

提问by Youddh

i am trying to execute the xxx.bat file for rename the file from my Android app and hear is my code

我正在尝试执行 xxx.bat 文件以从我的 Android 应用程序中重命名文件,然后听到的是我的代码

  Runtime.getRuntime().exec(Environment.getExternalStorageDirectory()+File.separator+"eduapp"+File.separator+"lock1.bat");

eduapp is Directory and lock1.bat is my bat file and content of it

eduapp 是目录,lock1.bat 是我的 bat 文件及其内容

ren /sdcard/eduapp .{ED7BA470-8E54-465E-825C-99712043E01C}

but when i run app it throes error like..

但是当我运行应用程序时,它会出现错误,例如..

java.io.IOException: Error running exec(). Command: [/mnt/sdcard/eduapp/lock1.bat] Working Directory: null Environment: null

basically i want to hide some folder from sdcard .is their any anther way to run .bat or hide folder from sdcard .

基本上我想从 sdcard 隐藏一些文件夹。是他们运行 .bat 或从 sdcard 隐藏文件夹的任何其他方式。

采纳答案by keltar

Because .bat is dos batch files, while android based on linux?.. It's 'mv', not 'ren'. It's not '.bat', it's '.sh' (but it doesn't matter, in fact). Also, you have to run /bin/sh and pass script file as parameter, or run 'mv' directly with parameters - you can't exec text file. But i'm sure java have it's own functions to move files, there is no need for shell scripts.

因为.bat 是dos 批处理文件,而android 是基于linux 的?.. 是'mv',不是'ren'。它不是“.bat”,而是“.sh”(但实际上这并不重要)。此外,您必须运行 /bin/sh 并将脚本文件作为参数传递,或者直接使用参数运行 'mv' - 您不能执​​行文本文件。但我确信 java 有它自己的功能来移动文件,不需要 shell 脚本。