Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 有没有办法将windows服务的pid保存在var中?_Batch File_Service - Fatal编程技术网

Batch file 有没有办法将windows服务的pid保存在var中?

Batch file 有没有办法将windows服务的pid保存在var中?,batch-file,service,Batch File,Service,我想制作一个批处理文件,检查BITS服务是否停止。 当它停止时,它启动它并通过一个循环PID将优先级设置为BITS服务。有人能帮我吗 net start BITS for /f "tokens=3" %A in ('sc queryex BITS ^| find "PID"') do wmic service where "ProcessID=%A" get caption,name,processid /value IF "!pid!" NEQ "0" ( wmic process wh

我想制作一个批处理文件,检查BITS服务是否停止。 当它停止时,它启动它并通过一个循环PID将优先级设置为BITS服务。有人能帮我吗

net start BITS
for /f "tokens=3" %A in ('sc queryex BITS ^| find "PID"') do wmic service where "ProcessID=%A" get caption,name,processid /value
 IF "!pid!" NEQ "0" (
  wmic process where processid= %A% CALL setpriority "realtime"
 )


你在你的帖子里贴了一些代码,你能告诉我们它是用来做什么的吗?这就是您为执行上面列出的任务而编写的脚本吗?如果是,请解释问题所在,或其结果?此网站不是来查看您的代码的,我们希望您告诉我们足够的信息,以便我们帮助您修复代码。我很想知道您为什么将服务视为一个进程,以及您希望将其优先级设置为实时的原因是什么。是的,启动BITS命令是“净启动BITS”但我会做一批,做我之前描述的。我很抱歉我的英语不好,而且我一点也没学,所以我向她要了一些代码。我想从BITs开始,将优先级设置为realtime,这样游戏才能因为连接而运行得更好。问题是通过获取服务PID来设置进程的优先级,因为我们无法在Windows下设置服务优先级,因为BITS由svchost实例托管,但有许多svchost。
1)
进程的单个实例可以托管多个服务;通过为承载BITS服务的
svchost
进程设置优先级,您将为该
svchost
特定实例承载的所有服务设置优先级<代码>2)连接性能受网络连接质量、响应时间、带宽等因素的影响,。。而不是按流程优先级。但是,最终由您决定如何处理获得的
PID
:只是显示它,终止进程,做一些有用/有害/无用的事情,……但据我所知,您的主要问题是,您很难将
PID
保存在变量中,然后再使用它(无论出于何种目的)。在这种情况下,我建议你改写你的问题,把重点放在你的主要问题上。