如何在.cmd或.bat文件中运行节点实用程序 [英] How to run a node utility in a .cmd or .bat file

查看:121
本文介绍了如何在.cmd或.bat文件中运行节点实用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows服务应用程序,我想在其中提供一个html页面以显示该服务的简单运行时信息。我发现了实用程序 inliner ,该实用程序使我可以将Web文件合并为单个html文件,这很容易通过运行在Windows服务中的自托管Web api进行服务。

I have a windows service application where I want to serve out a single html page to display simple runtime information for the service. 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.

我想自动运行脚本来构建单个html文件,因此将命令行放入.bat / .cmd文件,然后从 Visual Studio 2015 生成后事件中调用此文件。源html文件具有对脚本和CSS的一些引用,例如

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. The source html file has a couple of references to scripts and css, eg

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

.cmd(或.bat)文件的内容如下

The contents of the .cmd (or .bat) file are as follows

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

当我从命令提示符处运行以上尝试时,它工作正常,但是当我尝试并运行.bat文件,出现以下错误。

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

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

是否可以通过Visual Studio post build命令运行这样的节点命令?批处理/ cmd文件还是其他?我确实是直接从Post命令尝试的,而不是.cmd文件,但是仍然无法使其正常工作(尽管我可以获取它来生成输出html文件,但是它始终为空)

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? 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)

在此先感谢您提供任何指针。

Thanks in advance for any pointers here.

推荐答案

您的。蝙蝠文件具有UTF-8 字节顺序标记(BOM)

Your .bat file has a UTF-8 byte-order mark (BOM) at the start of it.

错误消息中 inliner.cmd 之前的三个额外字符是三个在代码页850 中构成UTF-8字节顺序标记的字符。

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.

尝试从文件中删除字节序标记。

Try removing the byte-order mark from the file.

这篇关于如何在.cmd或.bat文件中运行节点实用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆