在c#中调用windows脚本的方法
2005-07-07 09:53
405 查看
在程序中调用脚本,能够给应用增加很多灵活性,下面是两种调用脚本的方法
方法1:直接调用
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
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);
方法1:直接调用
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
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);
相关文章推荐
- 在c#中调用windows脚本的方法
- 在c#中调用windows脚本的方法
- 在c#中调用windows脚本的方法
- Unity中使用C#脚本调用JS脚本的使用方法
- windows 2008 下C#调用office组件访问拒绝的解决方法(failed due to the following error: 80070005 拒绝访问)
- C#使用技巧之调用JS脚本方法一
- windows 2008 下C#调用office组件访问拒绝的解决方法(failed due to the following error: 80070005 拒绝访问)
- C#调用脚本语言(三)-- IronJS 与 IronLua 简单方法性能比较
- [Unity] .lua脚本调用C#方法的一小点坑
- C#使用技巧之调用JS脚本方法二
- 在.Net Framework中调用Python的脚本方法 (以VB和C#为例)
- c#中跨线程调用windows窗体控件 .我们在做winform应用的时候,大部分情况下都会碰到使用多线程控制界面上控件信息的问题。然而我们并不能用传统方法来做这个问题,下面我将详细的介绍。
- C#使用技巧之调用JS脚本方法一
- C#调用脚本语言(三)-- IronJS 与 IronLua 简单方法性能比较
- C#使用技巧之调用JS脚本方法一
- windows 2008 下C#调用office组件访问拒绝的解决方法(failed du
- 如何使windows下的bat文件调用linux下的shell脚本的方法
- C#使用技巧之调用JS脚本方法二
- C#使用技巧之调用JS脚本方法一
- C#调用脚本语言(三)-- IronJS 与 IronLua 简单方法性能比较