简体   繁体   English

从NodeJS启动Windows程序

[英]Launch a Windows program from NodeJS

I know this has been answered a couple of times before, but that didn't work for me. 我知道之前已经回答过几次,但这对我没有用。

My Code is: 我的代码是:

var cp = require("child_process");
cp.exec("C:\Program Files\VideoLAN\VLC\vlc.exe");

When I start the JS file with NodeJS it doesn't do anything. 当我用NodeJS启动JS文件时,它什么也没做。 Can someone help me with this? 有人可以帮我弄这个吗?

You have to escape your backslashes and quote the path because it contains a space: 您必须转义反斜杠并引用路径,因为它包含空格:

var cp = require("child_process");
cp.exec('"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"');

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

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