简体   繁体   English

如何在.cmd或.bat文件中运行节点实用程序

[英]How to run a node utility in a .cmd or .bat file

I have a windows service application where I want to serve out a single html page to display simple runtime information for the service. 我有一个Windows服务应用程序,我想在其中提供一个html页面以显示该服务的简单运行时信息。 I found the utility inliner which allows me to combine my web files into a single html file, which is easy to serve up via self hosted web api running in the windows service. 我发现了实用程序inliner ,该实用程序可以将我的Web文件组合到一个html文件中,而该文件很容易通过Windows服务中运行的自托管Web api来提供。

I would like to auto run the script to build this single html file, so I put the command line into a .bat/.cmd file and then call this from Visual Studio 2015 post build event. 我想自动运行脚本来构建此html文件,因此我将命令行放入.bat / .cmd文件中,然后从Visual Studio 2015生成后事件中调用它。 The source html file has a couple of references to scripts and css, eg 源html文件有一些对脚本和CSS的引用,例如

<head>
  <link href="lib\css\bootstrap.css" rel="stylesheet" type="text/css" />
  <script src="lib\js\jquery-2.2.1.js"></script>
  <script src="_default.js"></script>
</head>

The contents of the .cmd (or .bat) file are as follows .cmd(或.bat)文件的内容如下

 inliner.cmd -vs _default.html > default.html

When I run the above tried from the command prompt it works fine, but when I try and run the .bat file I get the following error.. 当我从命令提示符处运行上述尝试时,它工作正常,但是当我尝试运行.bat文件时,出现以下错误。

'´╗┐inliner.cmd' is not recognized as an internal or external command, operable program or batch file.

Is there a way to run such a node command from a Visual Studio post build command, either via a batch/cmd file or otherwise? 有没有一种方法可以通过批处理/ cmd文件或其他方式从Visual Studio的后生成命令中运行这样的节点命令? I did try straight from the Post command, rather than the .cmd file, but would still not get it to work correctly (though I could get it to produce the output html file, but it was always empty) 我确实直接尝试了Post命令,而不是.cmd文件,但仍然无法使其正常工作(尽管我可以获取它来生成输出html文件,但始终为空)

Thanks in advance for any pointers here. 在此先感谢您的指导。

Your .bat file has a UTF-8 byte-order mark (BOM) at the start of it. 您的.bat文件的开头具有UTF-8 字节顺序标记 (BOM)。

The three extra characters in your error message that precede inliner.cmd are the three characters that make up a UTF-8 byte order mark in code page 850 . 错误消息中inliner.cmd之前的三个额外字符是组成代码页850中的UTF-8字节顺序标记的三个字符。

Try removing the byte-order mark from the file. 尝试从文件中删除字节顺序标记。

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

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