简体   繁体   中英

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.


I have a CasperJS script that I need to run from my C#.NET Visual Studio Application. 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.

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

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. 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.

在此处输入图片说明

link to image: http://i.stack.imgur.com/xtGYq.png

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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