运行 个进程来自 Visual Studio

Running Processes from Visual Studio

casper.js 代码如下所示。

var casper = require('casper').create();
var fs = require('fs');
var path = 'test.txt';

fs.touch(path);

casper.start('http://www.google.com', function() {
    fs.write(path, this.getHTML(), 'w');
});

casper.run();

我是这样调用流程的。

System.Diagnostics.Process.Start(@"C:\CasperJS\casperjs-casperjs-b4f7669\bin\casperjs", @"C:\casper\casper.js");

当我 运行

时有效
>casperjs casper.js 

从命令行,但当我尝试从 visual studio 运行 时不是。有什么想法吗?

通过将 js 文件移动到与我的 application.exe 文件相同的目录中,可以轻松解决此问题。然后我将 CasperJS 添加到我的路径中,这样就可以在不需要指定完整路径的情况下调用它。我的 C# 代码最终看起来像这样。

Process.Start("casperjs", "casp.js");

其中 casperjs 是 casperjs 程序,casp.js 是我要 运行 的 javascript 文件。