简体   繁体   English

从批处理文件在FOR中调用WMIC命令会使系统无限期地挂起系统

[英]Calling a WMIC command inside FOR from a batch file hangs the system for indefinite time

I have a batch file, that calls a WMIC command. 我有一个批处理文件,该文件调用WMIC命令。 The WMIC command is inside a for loop. WMIC命令位于for循环内。

Calling this batch file results in indefinite hang, and it seems to hang for more than 2 to 3 hours, only way to get out is by terminating the process by pressing CTRL+C. 调用此批处理文件将导致无限期的挂起,并且似乎挂起超过2到3个小时,唯一退出该方法的方法是通过按CTRL + C终止该过程。

The WMIC command is: WMIC命令是:

FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year
/Format:table')

The script hangs only when it is executed on windows server 2003, it works perfectly fine on other operating system. 该脚本仅在Windows Server 2003上执行时才挂起,在其他操作系统上也可以正常工作。

The server that has server 2003 also has AMD processor, is this the cause? 具有Server 2003的服务器也具有AMD处理器,这是原因吗? or is there something else that I am missing? 还是我还缺少其他东西?

By the way the script is called in the line: 通过在行中调用脚本的方式:

 %LOGMESSAGE%  do something . 

And LOGMESSAGE variable is set to call the script containing the WMIC command as follow: 并将LOGMESSAGE变量设置为调用包含WMIC命令的脚本,如下所示:

 set LOGMESSAGE=call path_to_the_script\WMIC.cmd

Any suggestion is very much helpful, thanks a ton in advance. 任何建议都非常有帮助,在此先感谢您的帮助。

This works for me: 这对我有用:

FOR /F "skip=1 tokens=1-6" %%A IN ('echo. ^| WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') FOR / F“跳过= 1令牌= 1-6” %% A IN('echo。^ | WMIC路径Win32_LocalTime Get Day ^,Hour ^,Minute ^,Month ^,Second ^,Year / Format:table')

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

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