简体   繁体   English

如何打开命令提示符并通过C#运行CasperJS脚本?

[英]How do I open up Command Prompt and run a CasperJS script via C#?

Solution: I rebooted my computer and it worked. 解决方案:我重新启动了计算机,它开始工作了。 It must have not picked up on the change to the PATH that I executed before building this project. 在构建此项目之前,它一定没有接受对我执行的PATH所做的更改。


I have a CasperJS script that I need to run from my C#.NET Visual Studio Application. 我有一个CasperJS脚本,需要从C#.NET Visual Studio应用程序中运行。 I can open up CMD and run the script no problem from Start > Run > CMD, but if I open CMD through my Visual Studio application, I can't run the scripts. 我可以从“开始”>“运行”>“ CMD”打开CMD并运行脚本,但是如果通过Visual Studio应用程序打开CMD,则无法运行脚本。

Here is a picture. 这是一张照片。

The one on the left is the Command Prompt initiated from the application, the right is the other. 左边的一个是从应用程序启动的命令提示符,右边的是另一个。 在此处输入图片说明

sorry about the image, here is the link: http://i.stack.imgur.com/kuJsg.png 对于图片感到抱歉,这是链接: http : //i.stack.imgur.com/kuJsg.png

This is all the button does. 这就是按钮的全部功能。

private void button1_Click(object sender, EventArgs e)
{
    System.Diagnostics.Process.Start("CMD.exe");
}

I added CasperJS to my PATH environment variables and I'm able to run the script no problem, until I use Visual Studio to open Command Prompt, then it loses the path to CasperJS. 我将CasperJS添加到我的PATH环境变量中,并且我可以运行脚本没有问题,直到使用Visual Studio打开命令提示符,然后它才失去了通往CasperJS的路径。 I ran the PATH command and CasperJS is there, but if I run the PATH command in the Command Prompt that was opened by my application, its not there. 我运行了PATH命令,CasperJS在其中,但是如果我在应用程序打开的命令提示符中运行PATH命令,则该命令不存在。

在此处输入图片说明

link to image: http://i.stack.imgur.com/xtGYq.png 链接到图像: http : //i.stack.imgur.com/xtGYq.png

重新启动PC,它更正了PATH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM