Windows 10: How to output day of week to variable in batch

  1.    15 Jan 2016 #1

    How to output day of week to variable in batch


    Hi all,

    I am trying to write a batch file in Windows 10 to output day of week (Monday, Tuesday etc) to variable do that I can do certain procedures on differnt days o the week and am having major problems.

    If I type DATE /T at command prompt I get 15/01/16 and no day of week.

    I have change regional setting so that long date is in correct format but still if I type DATE /T at command prompt I get 15/01/16 and no day of week.

    All help appreciated.

    Thank you.
      My ComputerSystem Spec


  2. Posts : 11,218
    Windows 10 Pro
       15 Jan 2016 #2

    DATE /T shows the date, not day of the week. You need WMIC command to get the day of the week:

    Code:
    wmic path win32_localtime get dayofweek

    Click image for larger version. 

Name:	2016_01_15_20_27_231.png 
Views:	17 
Size:	20.0 KB 
ID:	58993

    The output will be a number from 1 to 7, 1 being either Sunday or Monday depending on what is your local setting, if the first day of the week is Sunday or Monday. In my case, European system and Monday as the first day of the week, the command shown in above screenshot (yellow highlight) gave just now the output (green highlight) as 5 (Friday).

    Kari
      My ComputerSystem Spec


 

Related Threads
Solved Writhing Batch File in General Support
Here is my batch file but it will not delete the file? Must be missing something :( del "C:\Users\Larry\AppData\Local\TractorParts\tractor\ConfigSetting" Trying to delete the ConfigSetting File
Chaps... I have a desktop running with a few apps 24/7 feeding to a network, on the rare occasion it drops or restarts due to some update or power outage I thought I could write a simple batchfile just to restart everything automatically. ...
Start a program from a batch file in Software and Apps
I'm trying to create a batch file that should - call another batch file - start a program and then wait for the program to close - call another batch file My goal with this is to work around an issue in Windows 10 where the screensaver won't...
System Info Batch File in Chillout Room
Hi Everyone, I thought it may be interesting to get input from others regarding this batch file. I was hoping for suggestions about: Information to add to the report. Ways of making the current code more efficient. Etc... A while back i...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 10:47.
Find Us