目录名称包含空格时,使用BAT文件启动nodejs http服务器 [英] Starting a nodejs http-server using a BAT file when the directory name contains a space

查看:360
本文介绍了目录名称包含空格时,使用BAT文件启动nodejs http服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上有一个.bat文件,我希望能够将其复制到任何新文件夹并双击以启动http服务器.它仅包含一行,即:

I have a .bat file on windows, which i want to be able to copy to any new folder and doubleclick to start a http server. It only contains one line which is:

http-server %~dp0

%~dp0提取.bat文件当前所在目录的完整路径.相信此答案.

The %~dp0picks up the full path to whatever directory the .bat file is currently in. Credit to this answer for that.

当文件路径中的所有文件夹都不包含空格时,它会很好地工作.

It works well when none of the folders in the file path contain a space.

如何修改批处理文件以解决路径中某些目录名称中包含空格的情况?

How can i modify the batch file to account for situations where some directories in the path contain a space in the name?

欢呼

PS:这是我的新手:)

PS: Im new to this :)

推荐答案

事实证明,删除%~dp0并仅包含http-server,批处理文件中没有其他内容可以使其正常工作!

It turns out removing the %~dp0 and just having http-server and nothing else in the batch file makes it work!

然后它提供了当前目录中的所有内容,如下所示:

It then serves up whatever is in the current directory as shown:

这篇关于目录名称包含空格时,使用BAT文件启动nodejs http服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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