我需要从我的 .NET 应用程序执行 shell 命令,这与os.execute http://lua-users.org/wiki/OsLibraryTutorial(该页面下方一点)Lua http://en.wikipedia.org/wiki/Lua_%28programming_language%29。然而,粗略搜索后我什么也没找到。我该怎么做?
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "blah.lua arg1 arg2 arg3";
p.StartInfo.UseShellExecute = true;
p.Start();
另一种方法是使用P/Invoke http://en.wikipedia.org/wiki/Platform_Invocation_Services并直接使用 ShellExecute:
[DllImport("shell32.dll")]
static extern IntPtr ShellExecute(
IntPtr hwnd,
string lpOperation,
string lpFile,
string lpParameters,
string lpDirectory,
ShowCommands nShowCmd);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)