China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 12:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » What does "%~1" "%~0" mean View 1,680 Replies 12
Original Poster Posted 2008-10-28 10:26 ·  中国 四川 南充 电信
新手上路
Credits 8
Posts 5
Joined 2008-10-28 09:52
17-year member
UID 129316
Gender Male
Status Offline
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 ]
Floor 2 Posted 2008-10-28 12:11 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,608
Posts 780
Joined 2007-10-07 10:19
18-year member
UID 99089
Gender Male
Status Offline
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
Floor 3 Posted 2008-10-28 22:22 ·  中国 四川 南充 电信
新手上路
Credits 8
Posts 5
Joined 2008-10-28 09:52
17-year member
UID 129316
Gender Male
Status Offline
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 ]
Floor 4 Posted 2008-10-28 22:50 ·  中国 广东 深圳 电信
新手上路
坚持学习
Credits 18
Posts 15
Joined 2008-10-18 10:49
17-year member
UID 128642
Gender Male
Status Offline
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?
Floor 5 Posted 2008-10-28 23:02 ·  中国 四川 南充 电信
新手上路
Credits 8
Posts 5
Joined 2008-10-28 09:52
17-year member
UID 129316
Gender Male
Status Offline
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.
Floor 6 Posted 2008-10-28 23:11 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Why not describe the background of the entire problem, your complete thoughts, and the problem in the top post all at once?
Floor 7 Posted 2008-10-28 23:46 ·  中国 广东 深圳 电信
新手上路
坚持学习
Credits 18
Posts 15
Joined 2008-10-18 10:49
17-year member
UID 128642
Gender Male
Status Offline
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.
Floor 8 Posted 2008-10-29 00:07 ·  中国 四川 南充 电信
新手上路
Credits 8
Posts 5
Joined 2008-10-28 09:52
17-year member
UID 129316
Gender Male
Status Offline
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.
Floor 9 Posted 2008-10-29 10:30 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Dive more, read more tutorials.
if %Hour% geq 18 (
if %Hour% leq 22 (
d:\ntsd\shutdown.exe
goto :eof
)
)
Floor 10 Posted 2010-04-21 02:11 ·  中国 广东 深圳 电信
初级用户
Credits 38
Posts 32
Joined 2010-04-07 22:43
16-year member
UID 164009
Gender Male
Status Offline
: I'm a super noob
Know what %1 is, but don't know what %~1 is
Floor 11 Posted 2010-04-21 11:03 ·  中国 广东 深圳 电信
初级用户
★★
游手好闲 + 无所事事 ..
Credits 194
Posts 167
Joined 2007-04-30 09:43
19-year member
UID 87022
Gender Male
Status Offline
```
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
)
```
Floor 12 Posted 2010-04-21 13:01 ·  中国 吉林 长春 电信
初级用户
Credits 69
Posts 46
Joined 2010-03-18 11:14
16-year member
UID 162446
Gender Male
From 山东
Status Offline
%0 and %~0 have the same effect, then %1 and %~1 should be the same too
Floor 13 Posted 2010-04-21 17:11 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
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
Forum Jump: