[英]Haxe Run System Commands as an adminstrator
As I am very new to haxe. 因为我是haxe的新手。
The following is my program in haxe where I am trying to retrieve the list of files opened in windows client. 以下是我在haxe中的程序,在该程序中我试图检索在Windows客户端中打开的文件列表。 Openfiles is the command which gives the list of files opened in windows machine , which needs to be executed as an administrator. Openfiles是提供Windows机器中打开的文件列表的命令,需要以管理员身份执行。 I am failing to execute the program which is giving no output. 我无法执行没有输出的程序。
class Hello {
public static function main() {
trace("Hello World!");
if(Sys.systemName()=="Windows"){
//var x = Sys.command("Openfiles",[]);
var output = new sys.io.Process("ipconfig", []).stdout.readAll().toString();
trace("output:::"+output);
}
if(Sys.systemName()=="Linux"){
//var x = Sys.command("Openfiles",[]);
var output = new sys.io.Process("ifconfig", []).stdout.readAll().toString();
trace("output:::"+output);
}
}
}
How to execute Openfiles system command as an administrator ? 如何以管理员身份执行Openfiles系统命令?
for Linux you can do this: 对于Linux,您可以执行以下操作:
var output = new Process("bash", ["-c 'echo rootS_PASswoRd | sudo -S ifconfig'"]).stdout.readAll().toString();
trace("output:::"+output);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.