在c#中调用windows脚本的方法
方法1:直接调用
CODE:
|
|
System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName="wscript"; proc.StartInfo.Arguments=" hello.js"; proc.StartInfo.UseShellExecute = false; proc.Start(); |
|
方法2:
使用MS的Windows Script Control
CODE:
|
|
string scr = "function hello(){var WshShell = new ActiveXObject(\"WScript.Shell\");" +"var code = \"WScript hello.js\";" +"WshShell.Exec(code);}"; MSScriptControl.ScriptControl sc = new ScriptControl(); sc.Language = "JScript"; sc.AllowUI = true; sc.AddCode(scr); object[] parameters = new Object[0]; sc.Run("hello",ref parameters); |
|
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。