中国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-12 13:23
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » What does "%~1" "%~0" mean
Printable Version  1,681 / 12
Floor1 zhaoyi Posted 2008-10-28 10:26
新手上路 Posts 5 Credits 8
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 ]
Floor2 huahua0919 Posted 2008-10-28 12:11
银牌会员 Posts 780 Credits 1,608
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
Floor3 zhaoyi Posted 2008-10-28 22:22
新手上路 Posts 5 Credits 8
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 ]
Floor4 newsuper Posted 2008-10-28 22:50
新手上路 Posts 15 Credits 18
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?
Floor5 zhaoyi Posted 2008-10-28 23:02
新手上路 Posts 5 Credits 8
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.
Floor6 HAT Posted 2008-10-28 23:11
版主 Posts 5,017 Credits 9,023
Why not describe the background of the entire problem, your complete thoughts, and the problem in the top post all at once?
Floor7 newsuper Posted 2008-10-28 23:46
新手上路 Posts 15 Credits 18
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.
Floor8 zhaoyi Posted 2008-10-29 00:07
新手上路 Posts 5 Credits 8
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.
Floor9 HAT Posted 2008-10-29 10:30
版主 Posts 5,017 Credits 9,023
Dive more, read more tutorials.
Floor10 Lin7uan Posted 2010-04-21 02:11
初级用户 Posts 32 Credits 38
: I'm a super noob
Know what %1 is, but don't know what %~1 is
Floor11 exzzz Posted 2010-04-21 11:03
初级用户 Posts 167 Credits 194
```
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
)
```
Floor12 luuk Posted 2010-04-21 13:01
初级用户 Posts 46 Credits 69 From 山东
%0 and %~0 have the same effect, then %1 and %~1 should be the same too
Floor13 slore Posted 2010-04-21 17:11
铂金会员 Posts 2,478 Credits 5,212
for /?
Press Enter for about 5 seconds, and you can see what you need.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023