Title: Create a batch file to load a webpage when the date and time are correct
Tags: datetime;batch-file;webpage
Question: I am trying to get a webpage to load when the date and time are correct. The code I have come up with is:

```@echo off
:repeat
set CurrentTime=%time:~0,2%.%time:~3,2%
set CurrentDate=%date:/=-%
echo.
echo %CurrentDate% %CurrentTime%
echo.
IF %CurrentTime% == Tue 08-04-2014 13.04 goto load
timeout /t 1 &gt;nul
goto repeat
:load
start/MAX iexplore.exe"" "http://www.youtube.com.au"
timeout /t 6 &gt;nul
```

It will work if I remove the CurrentDate and the date from the IF statement but it won't if I don't. I do need the date and time to work.
Thanks.



Here is another answer: Aditionally to the solution that Magoo has posted, note that ```%DATE%``` returns the current date using the short date format that is fully and endlessly customizable by the users. One user may configure its system to return ```Tue 08/04/2014``` and another user may choose ```Apr8th14```. It's a complete nightmare for a BAT programmer. Even in the same computer. This is also true for the ```~t``` modifier when expanding a variable containing a filename.

There are several solutions, google a bit to find them. The easiest in my opinion is to use WMIC

``` WMIC Path Win32_LocalTime Get Day,Hour,Minute,Month,Second,Year /Format:table 
```

returns the date in a convenient way to directly parse with a ```FOR``` command.

``` FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
    SET /A currentdate=%%F*10000+%%D*100+%%A
 )
 IF "%currentdate"=="20140408" goto load
```


Here is another answer: You can also use a scheduled task if that suits the reason for you wanting to load the page.


Here is another answer: ```IF "%date% %Time%"=="Tue 08-04-2014 13.04" goto load
```

shoud work for you. You need to use the "quotes" to group the string as a single entity, otherwise ```IF``` has no way of telling whether the ```==``` is a part of the string to be compared or it's the comparison operator. (and that assumes that your date format is ```Tue 08-04-2014``` and time is ```13.04```)


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:04/08/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<datetime><batch-file><webpage>', 'Title': 'Create a batch file to load a webpage when the date and time are correct', 'ViewCount': 81, 'id': 22927079, 'user_AboutMe': None, 'user_AccountId': 4289968.0, 'user_DisplayName': 'user3506608', 'user_Reputation': 73.0, 'user_Views': 16.0, 'user_id': 3506608.0}}