|
zhaoyi
新手上路

积分 8
发帖 5
注册 2008-10-28
状态 离线
|
『楼 主』:
"%~1" "%~0"是什么意思
使用 LLM 解释/回答一下
if "%~1"=="" start /min "" "%~0" h&exit
有一个批处理第一句就是这个我看了半天看不懂,
@echo off
for /f "delims=: tokens=1*" %%i in ('time /t') do call :Comp %%i %%j
goto :eof
:Comp
set /a Hour=%1
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 01 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 02 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 03 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 04 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 05 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 06 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 07 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 13 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 14 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 15 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 16 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 17 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 23 (d:\ntsd\shutdown.exe & goto :eof)
shutdown.exe是一个关机程序
这里面的能不能简化下,,IF我到现在没找到这样的语名,,大于且小于,,
不然就不会用这个笨方法了
也就4楼说的那样,早上8:00-12:00,晚上18:00-22:00可以运行,其他时间都关机
这个批处理怎么写比较简单!
Last edited by zhaoyi on 2008-10-28 at 23:28 ]
if "%~1"=="" start /min "" "%~0" h&exit
There is a batch processing first sentence is this I read for a long time did not understand,
@echo off
for /f "delims=: tokens=1*" %%i in ('time /t') do call :Comp %%i %%j
goto :eof
:Comp
set /a Hour=%1
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 01 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 02 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 03 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 04 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 05 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 06 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 07 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 13 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 14 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 15 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 16 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 17 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 00 (d:\ntsd\shutdown.exe & goto :eof)
if %Hour% equ 23 (d:\ntsd\shutdown.exe & goto :eof)
shutdown.exe is a shutdown program
Can simplify here,, IF I have not found such a statement,, greater than and less than,,
Otherwise, I would not use this stupid method,
Also 4 floors said that, from 8:00 - 12:00 in the morning, from 18:00 - 22:00 in the evening can run, all other times are shut down
How to write this batch processing more simply!
Last edited by zhaoyi on 2008-10-28 at 23:28 ]
|
|
2008-10-28 10:26 |
|
|
huahua0919
银牌会员
    
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
了解進程的相關信息 tasklist
會試用findstr 查找相關字符
會試用for簡化程序
要了解%1 %2 %3 %0 等參數所代表的意思
Understand the relevant information of processes tasklist
Will use findstr to find relevant characters
Will use for to simplify the program
To understand the meanings of parameters such as %1 %2 %3 %0
|
|
2008-10-28 12:11 |
|
|
zhaoyi
新手上路

积分 8
发帖 5
注册 2008-10-28
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
大哥你能不能给我改改.,我这个也太差了,太繁锁了
Last edited by zhaoyi on 2008-10-28 at 22:25 ]
Big brother, can you help me revise it? Mine is also too bad and too cumbersome.
Last edited by zhaoyi on 2008-10-28 at 22:25 ]
|
|
2008-10-28 22:22 |
|
|
newsuper
新手上路
 坚持学习
积分 18
发帖 15
注册 2008-10-18
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
不知道楼主这个程序是要干什么呢?早上8:00-12:00,晚上18:00-22:00可以运行,其他时间都关机?
这样的话,用at,或者schtasks限制登录时间就好了啊,莫非有其他意思?
I don't know what the owner of the post is going to do with this program. It can run from 8:00 am to 12:00 and from 18:00 to 22:00 in the evening, and shut down at other times? In that case, you can use at or schtasks to limit the login time. Could there be other meanings?
|
|
2008-10-28 22:50 |
|
|
zhaoyi
新手上路

积分 8
发帖 5
注册 2008-10-28
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
其实我想说实话,,at,或者schtasks命令不能在登陆帐号以前..根本无法运行..我尝试过N久了都不行...只能用这个办法了,然后把这个批得理加在注册表里,,hklm_system_CurrentControlSet_services里,做成系统服务形式,启机到登陆界面就自己动运行,最主要是防家里孩子过度上网,但IF做出来的效果太长了,,我想应该可简化面成几行.
Actually, I want to tell the truth,, the at or schtasks commands cannot run before logging in.. I've tried for a long time and it doesn't work... I can only use this method, and then add this batch file to the registry,, in hklm_system_CurrentControlSet_services, make it into a system service form, and it runs by itself when booting to the login screen. The main thing is to prevent children at home from overusing the Internet, but the IF made is too long... I think it can be simplified into a few lines.
|
|
2008-10-28 23:02 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 6 楼』:
Re 5楼
使用 LLM 解释/回答一下
为何不把整个问题的背景和你的完整想法以及问题在顶楼一次性描述清楚呢?
Why not describe the background of the entire problem, your complete thoughts, and the problem in the top post all at once?
|

 |
|
2008-10-28 23:11 |
|
|
newsuper
新手上路
 坚持学习
积分 18
发帖 15
注册 2008-10-18
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
那就给他一个限制时间的账户啊
net user new 123 /add
net user new /time:M-Su,08:00-12:00,18:00-22:00
以后让他用new这个账户登录就可以了啊
Then give him an account with a time limit.
net user new 123 /add
net user new /time:M-Su,08:00-12:00,18:00-22:00
Then he can log in with the new account in the future.
|
|
2008-10-28 23:46 |
|
|
zhaoyi
新手上路

积分 8
发帖 5
注册 2008-10-28
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
楼住这个太过份了吧,,,那以后你老了想做什么,,那儿子就说:"爸!我一定会把你当宾客看待,不是说宾客是上帝吗"呵呵算了看来没人解决,,那就临时用,.
The building host is too excessive,,, then what do you want to do when you are old in the future,, then the son says: "Dad! I will definitely treat you as a guest, isn't it said that guests are God" Hehe, forget it, it seems no one can solve it,, then use it temporarily.
|
|
2008-10-29 00:07 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 9 楼』:
Re 8楼
使用 LLM 解释/回答一下
多潜水,多看教程。
if %Hour% geq 18 (
if %Hour% leq 22 (
d:\ntsd\shutdown.exe
goto :eof
)
)
Dive more, read more tutorials.
if %Hour% geq 18 (
if %Hour% leq 22 (
d:\ntsd\shutdown.exe
goto :eof
)
)
|

 |
|
2008-10-29 10:30 |
|
|
Lin7uan
初级用户
 
积分 38
发帖 32
注册 2010-4-7
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
<img src="images/smilies/face-surprise.png" align="absmiddle" border="0">我是超菜菜鸟
知道什么是%1,但不知道什么是%~1
: :oI'm a super noob
Know what %1 is, but don't know what %~1 is
|
|
2010-4-21 02:11 |
|
|
exzzz
初级用户
  游手好闲 + 无所事事 ..
积分 194
发帖 167
注册 2007-4-30
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
if /i %time:~0,2% gtr 10 (
if /i %time:~0,2% lss 14 (
echo 现在时间大于10点且小于14点,将关机
shutdown -f -s -t 100
) else (
echo 时间大于14点,不关机
)
) else (
echo 时间小于10点,不关机
)
```
if /i %time:~0,2% gtr 10 (
if /i %time:~0,2% lss 14 (
echo It is between 10:00 and 14:00 now, will shut down
shutdown -f -s -t 100
) else (
echo It is after 14:00, no shutdown
)
) else (
echo It is before 10:00, no shutdown
)
```
|

|
|
2010-4-21 11:03 |
|
|
luuk
初级用户
 
积分 69
发帖 46
注册 2010-3-18 来自 山东
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
%0和%~0一样的效果吧,那么%1和%~1也应该一样吧
%0 and %~0 have the same effect, then %1 and %~1 should be the same too
|
|
2010-4-21 13:01 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
for /?
回车5小左右吧,你就能看到你要的东西了。
for /?
Press Enter for about 5 seconds, and you can see what you need.
|

S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2010-4-21 17:11 |
|
|