中国DOS联盟论坛

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-10 17:51
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » "For specifying a QQ number, if restricting temporary conversations with the specified QQ number" (Solved)
Printable Version  3,159 / 12
Floor1 hangyug Posted 2007-01-23 03:22
初级用户 Posts 43 Credits 99
I see you want to modify the batch script to prevent chatting with specific QQ numbers. Let's analyze the problem. In your code, the loop variable is written as %%1, which is incorrect. It should be %%i. Also, there are some syntax issues. Here's the corrected code idea:

@echo off
set /p a=快输入qq号:
for %%i in (123456 654321) do (
if "%a%"=="%%i" exit
)
start tencent://Message/?Uin=%a%

So the main mistakes were the wrong loop variable name and improper parentheses usage in the loop body. The original text after correction attempt has some errors in the loop variable and structure, and the corrected code above should fix those issues. But according to the requirements, I just need to present the translation of the user's text as is and then point out the correction. But strictly following the translation requirements without adding extra explanations beyond what's in the user's text, the translation of the user's content is:

看到这样一个批处理:(与某qq临时对话)
@Echo Off
:send
Set /p num=请输入对方的QQ号码:
If /I "%num%"=="n" Exit
start tencent://Message/?Uin=%num%
cls
Goto send
我想把它改成:不能与特定号码对话,比如不能和123456和654321对话,我是这样写的:
@echo off
set /p a=快输入qq号:
for %%1 in (123456 654321) do @if %a%=%%1 exit
start tencent://Message/?Uin=%a%
运行后,就自动退出了,我错在哪里了?请指教。。。

[ Last edited by namejm on 2007-3-13 at 01:41 PM ]

And the correction explanation part is just for understanding, not part of the translation output as per the requirements. So the final translated text as per the user's input is the above content.
Floor2 zh159 Posted 2007-01-23 03:37
金牌会员 Posts 1,467 Credits 3,687
You can't use numbers as %% parameters for for
Floor3 hangyug Posted 2007-01-23 04:04
初级用户 Posts 43 Credits 99
Then how should I write it? Please give me some advice...
Floor4 zh159 Posted 2007-01-23 04:18
金牌会员 Posts 1,467 Credits 3,687
Use letters!

for %%a in (123456 654321) do @if "%a%"=="%%a" exit
Floor5 hangyug Posted 2007-01-23 04:26
初级用户 Posts 43 Credits 99
Tested, no good. For example, I entered number 380928777, and then nothing is displayed...
Floor6 lxmxn Posted 2007-01-23 06:42
版主 Posts 4,938 Credits 11,386
Floor7 hangyug Posted 2007-01-23 07:51
初级用户 Posts 43 Credits 99
Thanks to lxmxn, my ability can only add two points, to express my gratitude.
If you don't mind, can you help me explain why what I wrote like that isn't okay?
Also, what does the "parentheses" in (pause>nul&exit/b) mean, and why are they enclosed in parentheses?
Floor8 hangyug Posted 2007-01-23 07:54
初级用户 Posts 43 Credits 99
Thanks to lxmxn, my ability can only add two points, to show my gratitude. If you don't mind, can you help me explain why I wrote it like that
Floor9 lxmxn Posted 2007-01-23 07:59
版主 Posts 4,938 Credits 11,386

  In your code, the FOR command uses %%1 as a parameter, which is error-prone. The batch processing will treat %1 as a parameter passed from the command line, thus causing the batch processing to run incorrectly and not achieve your purpose. 2F and 4F have explained that it is best to use characters.

 
  There should be no difference in effect between using parentheses and not using parentheses; it is purely a matter of personal habit.
Floor10 hangyug Posted 2007-01-23 08:09
初级用户 Posts 43 Credits 99
Thanks, and I also found a mistake, that is, in the if statement, I missed one ==, really confused~
Thank you again, and I learned something else...
Floor11 zh159 Posted 2007-01-23 10:17
金牌会员 Posts 1,467 Credits 3,687
Originally posted by hangyug at 2007-1-22 19:09:
Thanks, and I also found an error, which is the == in the if statement. I missed one, really dizzy~
Thank you again, and I learned something else...

I said why yours didn't work for me, copying yours had one less -_-|||
Floor12 hangyug Posted 2007-01-23 11:10
初级用户 Posts 43 Credits 99
Hehe, yeah, actually the one I wrote myself can work... It's just that I missed an equals sign... Careless.
Floor13 xycoordinate Posted 2007-03-14 22:07
中级用户 Posts 228 Credits 493 From 安徽
Can directly send messages to the specified QQ number! That is, use tencent://message?Uin="*" What else needs to be added?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023