根据当前日期创建 Windows 2003 快捷方式或 MKLINK?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5938257/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:49:15  来源:igfitidea点击:

Create windows 2003 shortcut or MKLINK based on current date?

windowssymlinkshortcutmklink

提问by Mick Knutson

I need to create a symlink/shortcut on the prod servers that will alias:

我需要在将别名的 prod 服务器上创建一个符号链接/快捷方式:

agent_ivr_general_info.CURRENT

to

agent_ivr_general_info.[todays date].log

because I have daily rolling logs cush as:

因为我每天都有滚动日志库什:

agent_ivr_general_info.2011-04-28.log

That I want to just open 1 LINK to get to CURRENT.

我只想打开 1 个链接以访问 CURRENT。

采纳答案by ewall

Hmm... I suppose one technique would be to use Sysinternals' JUNCTION.EXEwith a Scheduled Task that runs daily just after midnight, and uses something like the following to change the link:

嗯...我想一种技术是将Sysinternals 的 JUNCTION.EXE与每天午夜后运行的计划任务一起使用,并使用类似以下内容来更改链接:

cd TARGET_DIRECTORY
:: get date -- this only works for default US date, YMMV
set day=%DATE:~7,2%
set month=%DATE:~4,2%
set year=%DATE:~-4%
:: set %today% formatted as YYYY-MM-DD
set today=%year%-%month%-%day%
:: delete old link
junction -d CURRENT
:: create new one
junction -c CURRENT .\%today%