仅在星期一和星期四运行CMD批处理文件 [英] Running CMD batch file only on Mondays and Thursdays

查看:144
本文介绍了仅在星期一和星期四运行CMD批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些当前每天运行的批处理文件,它们基本上是在早上更新系统数据后打开系统文件(根据日期的不同,该时间可能会有所不同).

I have some batch files that currently run every day that basically open system files as soon as the system data is updated in the morning (which can be at different times depending on the day).

当前的批处理文件(从CMD创建)都运行一个简单的start:...命令来打开文件.

The current batch files (created from CMD) all run a simple start:... command to open the files.

我正在寻找一种仅在星期一和星期四运行某些批处理文件,而在其他任何一天都不打开程序的方法.基本上,如果批处理文件每天运行,除非在星期一或星期四,否则它将什么都不做,然后它将打开系统文件.

I am looking for a way to only run some of the batch files on Mondays and Thursdays, but not open the programs on any other day. Basically if the batch file runs every day, it would do nothing unless it was Monday or Thursday, and then it would open the system file.

推荐答案

您可以使用

wmic path win32_localtime get dayofweek

,它将为您提供一个参考星期几的数字(这会根据您的本地设置而变化,但通常星期日是0).

which will give you a number refering to the day of the week (this changes based on your local settings, but usually Sunday is 0).

您可以使用此语句和if语句来确定是否应运行代码.

You could use this and an if statement to decide whether the code should run.

这篇关于仅在星期一和星期四运行CMD批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆