中国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-09-23 16:42
47,812 topics / 349,917 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » How to make a batch file wait for input?
Printable Version  3,086 / 4
Floor1 yc2455 Posted 2006-05-25 18:31
新手上路 Posts 3 Credits 10
Similar to %1 in a batch file, but this parameter has to be supplied together when running the batch file, and sometimes I forget. Now I want the batch file to prompt for input, and then have the rest of the batch file process it according to what was entered.

The specific problem is this: on the server I need to back up some data, but the batch file can't automatically create a directory for the current date (I looked for tutorials on the forum and it seems none of them can do it; if there is some way, that would be even better, then I wouldn't have to enter it by hand like this), so I can only use the batch file to create a directory. But sometimes I forget to pass the %1 parameter to the batch file, so it would be best if the batch file could wait for the date to be entered, then create the directory according to the entered content, and finally copy the backup files into that directory.

I'd appreciate guidance from all the experts, thanks!
Floor2 3742668 Posted 2006-05-25 19:27
荣誉版主 Posts 718 Credits 2,013
The matter of creating a directory named with the current date has been discussed several times on this forum; I suggest you search carefully.
You can try entering the following command:

Note that in different environments the format of the %date% variable may not be exactly the same, so you can adjust it yourself for reference.
Also, if you need to wait for input and reference it in a script, you can try using the set command.

These are all fairly basic. I suggest reading Help and Support more, or looking through more old forum posts.
Floor3 yc2455 Posted 2006-05-26 07:26
新手上路 Posts 3 Credits 10
Thanks for the guidance, I really should study this properly. I hardly ever use it normally, so there are a lot of things I don't understand

But many of the commands above are only supported by the NT command line. They simply can't be used in 98 at all. Is there any other way to use this in 98? Please give me some more guidance, thanks!

[ Last edited by yc2455 on 2006-5-26 at 11:13 ]
Floor4 willsort Posted 2006-05-26 08:32
元老会员 Posts 1,512 Credits 4,432
Re yc2455:

set /p and %date% are both features of NTCMD, and can be used in command-line environments like XP, while the DOS version in Win98 is 7.1. Compared with MS-DOS6.22 and Win95's MS-DOS7.0, its batch syntax support is basically the same except for long filename handling and some details.

As for getting the date into an environment variable under Win98 or MS-DOS and then generating a directory based on it, there have also been discussions in this section. You can search past threads. Recently I plan to organize the date issue in batch files; it may take three days to a week, and when it's done I will post it in the Batch File Room. You're welcome to check it out.
Floor5 yc2455 Posted 2006-05-26 11:12
新手上路 Posts 3 Credits 10
Thanks for the reply, looking forward to it.....
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023