DOS批处理:将系统时钟提前N天?

发布于 2024-09-30 08:40:35 字数 112 浏览 0 评论 0原文

我需要一些指针来制作 MS-DOS 批处理“函数”,以将系统日历从当前日历提前 N 天。是否有更适合机器的命令,或者我是否坚持使用 DATE 及其一些弗兰肯黑客解析?

I need some pointer crafting an MS-DOS batch "function" to advance the system calendar N number of days from the current one. Is there a more machine-friendly command, or am I stuck with DATE and some Franken-hack parsing of it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

舟遥客 2024-10-07 08:40:35

在网上我最喜欢的批处理网站之一 Rob van der Woude 的脚本页面 中,您可以在 示例部分 一个名为 DateAdd.bat。它将根据给定的日期和偏移量计算并打印新的日期。

根据您的需要更改脚本或将其与您自己的脚本一起使用应该相当容易。如果您需要进一步的帮助,请联系我们。

On one of my favorite batch sites on the net Rob van der Woude's Scripting Pages you can find in the examples section a script called DateAdd.bat. It will calculate and print a new date based on a given date and offset.

It should be fairly easy to change the script to your needs or use it along with your own script. Get back to us if you need further help with that.

兮颜 2024-10-07 08:40:35

如果您真正使用的是 MS-DOS,而不是更高级的 cmd.exe,那么您的选择非常有限,因为变量操作非常糟糕。

我确实记得前世需要类似的东西。根据记忆,我们没有试图搞乱日期计算,而是简单地运行一个循环(每天一次迭代),并在循环内将时间设置为 23:59,然后等待五秒左右。不幸的是,我认为早于 ping 所以我们甚至无法使用 睡眠技巧 - 我们必须运行一个冗长的 goto 循环才能确定。

这样,DOS 自己就能确定“明天”是 9 月 31 日还是 10 月 1 日。

最后,这变得太麻烦了,所以我建议你做我们完成的事情。从 Borland 获取一份 Turbo C 的副本(或者 InPrise 或 Enchilada 或者无论它们现在被称为什么 - 对我来说它们永远博物馆网站 并编写一个快速的小 C 程序来为您完成此操作。

If you're truly using MS-DOS rather than the more advanced cmd.exe, your options are very limited since the variable manipulation was pretty bad.

I do remember needing something similar in a previous life. From memory, rather than trying to screw around with date calculations, we simply ran a loop (one iteration for each day) and, inside the loop, set the time to 23:59 then wait for five seconds or so. Unfortunately, I think that pre-dated ping so we couldn't even use the sleep trick - we had to run a lengthy goto loop to be certain.

That way, DOS itself figured out whether "tomorrow" was the 31st of September or 1st of October.

In the end, it became too much trouble so I would suggest you do what we finished up doing. Grab yourself a copy of Turbo C from Borland's (or InPrise or Enchilada or whatever they're called nowadays - they'll always be Borland to me) museum site and write a quick little C program to do it for you .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文