Take the 2-minute tour ×

HI I am tring to remember how to write a .bat file to run on certain date to change a user's password automaticly. The way I have tried is. @echo off date \t (if system date is 01/07/13) go to line 15 (if system date is 01/22/13) go to line 16 (if system date is 02/05/13) go to line 17 (if system date is 02/17/13) go to line 18 (if system date is 02/27/13) go to line 19

net user user password net user user password3 net user user password4 net user user password5 net user user password6

Can Anyone help me out

Ok I need more help please I have tried this both ways and I can not seem to get this to work can anyone help me out thanks

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You could shorten this to just

if %date%==01/07/13 net user user password

That's much shorter than having a label and a goto for every one.

share|improve this answer
It should look like if 01/23/2013==01/23/2013 goto :line15 –  Bali C Jan 18 '13 at 19:35
add comment

You should use gotos with labels.

Labels are made with :LABELNAME. Gotos are goto :LABELNAME.

Use this method to fetch the date--adapt it to return the date in the format you want. Use:

if %date%=="date/to/test" goto :LINE15

rem ...

net user user password2

Also, use exit or goto :EOF to end the batch file after each password change and after the main program (with the if tests). If not, the program will "fall through" to each net user statement and change the password several times until it becomes password6--obviously undesirable.

Hope this helps!!

share|improve this answer
add comment

Your Answer


