![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-07 11:16 |
48,040 topics / 350,125 posts / today 0 new / 48,252 members |
| DOS批处理 & 脚本技术(批处理室) » Been depressed for several days by a low-level Wimc bug |
| Printable Version 3,494 / 17 |
| Floor1 fastslz | Posted 2008-01-20 19:06 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
|
BUG symptom: cursor flashes and batch is interrupted. Environment: WinXP SP2. My original batch code was very long, and it took me days to dig out this bug. I thought some part of the code was unstable, but it turned out to be this low-level bug. Really depressed~ Everyone, please pay attention to using set /p= <nul>name.txt and wmic in the same batch in the future |
|
| Floor2 everest79 | Posted 2008-01-21 01:20 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
There should be a newly generated batch file in your working directory, right?
|
|
| Floor3 everest79 | Posted 2008-01-21 01:25 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
set /p=%keyname%<nul>name.txt
The same situation applies to following copy con file and more, but wmic will treat the input as a script |
|
| Floor4 fastslz | Posted 2008-01-21 12:47 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
|
The batch file was not generated in the current directory.
I originally just wanted to use set/p to generate a text without a newline character, but I didn't expect that then no parameters of wmic would work. |
|
| Floor5 fastslz | Posted 2008-01-21 12:58 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
|
Solution
```batch @echo off set keyname=微软真垃圾 set /p=%keyname%<nul>name.txt set /p=<nul>nul wmic /? pause ``` |
|
| Floor6 fastslz | Posted 2008-01-21 13:52 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
|
It seems the problem is still with the set/p parameter.
|
|
| Floor7 everest79 | Posted 2008-01-22 13:28 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
Originally posted by fastslz at 2008-1-21 12:47 PM: It's not that it didn't work, but after several redirections, for some reason, it activated the console input acquisition of wmic. You can enter at the command line and terminate with ctrl+z to generate a temporary script file for wmic. Any command that has the function of receiving data in the console will have such an error in such a batch file. According to your batch file, I think any command with this function has a potential handle, which is customized by the command and mainly used to complete pipeline transmission. |
|
| Floor8 vkill | Posted 2008-01-22 13:50 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
This is also okay
So when I write >file, I put > at the front |
|
| Floor9 vkill | Posted 2008-01-22 13:51 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
The spirit of the original poster is worthy of encouragement
|
|
| Floor10 qzwqzw | Posted 2008-01-24 20:34 |
| 银牌会员 Posts 636 Credits 2,343 | |
This is my post in another thread before I saw this topic. Now, after integrating the discussions of the two topics, I think it is very likely related to the problem of custom handles. That is to say, wmic may be using one of the custom handles from 3 to 9. And at this time, if set /p, copy con or pipe operations are used, there is a high probability that this custom handle will be "polluted", causing the input of wmic to be redirected to the console. And such "pollution" is globally effective in one command line session. The related discussion is as follows: http://www.cn-dos.net/forum/viewthread.php?tid=16942 [ Last edited by qzwqzw on 2008-1-24 at 08:36 PM ] |
|
| Floor11 fastslz | Posted 2008-01-24 20:40 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
|
everest79 also said that a temporary file would be generated, but I didn't find the temporary file here. It seems to be another kind of "handle pollution". Wmic is particularly sensitive to pipe characters
|
|
| Floor12 terse | Posted 2008-01-24 21:02 |
| 银牌会员 Posts 946 Credits 2,404 | |
|
This can continue
@echo off set keyname=Microsoft is really rubbish set /p=%keyname%<nul>name.txt START wmic /? |
|
| Floor13 qzwqzw | Posted 2008-01-24 21:12 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
```
@echo off s<nul>nul echo test wmic /? pause ``` Such code shows that the problem is not related to set /p, but related to the two redirection symbols < and > that appear in the code. This corresponds to the discussion in http://www.cn-dos.net/forum/viewthread.php?tid=16942. The start in floor 12 is a new command line session, and the problem can naturally be solved. But usually it is of little significance because it is difficult for us to transfer the output of wmic back to the original command line session. [ Last edited by qzwqzw on 2008-1-24 at 09:16 PM ] |
|
| Floor14 fastslz | Posted 2008-01-24 21:29 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
|
It can be seen from floor 6
@echo off >nul s<nul echo test wmic /? pause In this way, redirection will not have such a situation |
|
| Floor15 qzwqzw | Posted 2008-01-24 22:36 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
The specific reason must be related to the internal processing mechanism of WMIC. We can see some clues from that TempWmicBatchFile.bat. However, no matter what, we can't stop using the <nul>nul sentence pattern because of WMIC. So the following methods should be effective in batch processing: wmic /?<nul or cd.|wmic /? In this way, no matter what custom handles were used in front of the script, it ensures that what WMIC uses is consistent. But when running cd.|wmic /? in the command line, it prompts: Win32 error: The file is being used by another process, and the process cannot access it. What an interesting prompt!
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |