双引号和单引号会在Windows批处理脚本中产生问题以终止进程 [英] Double and single quote creates issue in Windows batch script to kill process

查看:143
本文介绍了双引号和单引号会在Windows批处理脚本中产生问题以终止进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用node.js和Windows批处理脚本,这些脚本会杀死具有特定端口的进程.

I'm using node.js and windows batch script which kills process with particular port.

它非常通过命令行杀死进程,但不能通过批处理脚本运行.我认为由于双引号和单引号会造成问题吗?

It kills process very through command line but it doesn't work through batch script. I think it creates problem due to double and single quotes?

就下面的代码而言,它发现处于LISTENING状态的3000个端口并杀死了该端口.

As far as below code is concerned, it finds 3000 port in LISTENING state and kills.

FOR /F "tokens=5 delims= " %P IN ('netstat -a -n -o ^| findstr :3000.*LISTENING') do (TaskKill.exe /PID %P /T /F)

推荐答案

关于您的代码的突出之处在于,关键字之后必须必须.

What stands out about your code is that there MUST be a space after the do keyword.

您没有指出要查找的字符串.使用默认的/r开关,它似乎是:3000 anynumberofanycharacters LISTENING.我希望这是用引号"括起来的,但不应有任何区别.

You don't indicate what string you're trying to locate. It appears to be :3000anynumberofanycharactersLISTENING using the default /r switch. I'd prefer that was in "quotes" but it shouldn't make a difference.

这篇关于双引号和单引号会在Windows批处理脚本中产生问题以终止进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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