VB Script or Batch File to insert date

I need to setup a script that I will execute through Windows Scheduler on a daily basis.

I currently run this command on our Windows 2008 Server:
D:\>robocopy d: r: /MIR /r:1 /w:1 /log:d:\backup04112010.txt

I need the date to automatically 04112010 to update when the script is run.  I don't care if it is a VB script or a simple batch file, but it just needs to work so I can automate this process.

Please let me know and Thanks!!!
tech-Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TakedaTCommented:
Like this?
for /f "tokens=1,2,3,4 delims=/ " %%a in ("%date%") do (
	set today=%%b%%c%%d
)

echo.D:\>robocopy d: r: /MIR /r:1 /w:1 /log:d:\backup\%today%.txt

Open in new window

0
Justin EllenbeckerIT DirectorCommented:
Give this a try:
tdate = Right("0" & Month(Now),2) & Right("0" & Day(Now),2) & Year
RunStr = "D:\robocopy d: r: /MIR /r:1 /w:1 /log:d:\backup" & tdate & ".txt"
Set wshell = CreateObject("WScript.Shell")
wshell.Run(RunStr)

Open in new window

0
merowingerCommented:
Execute the below listed vbscript (.vbs) in your task scheduler
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "robocopy d: r: /MIR /r:1 /w:1 /log:d:\backup" &Date &".txt",0,True

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Justin EllenbeckerIT DirectorCommented:
On mine on line 1 place (Now) behind  year otherwise it will not work here is the complete code.  Oh and Merowinger Date will return M/D/YYYY which is going to break his log.
tdate = Right("0" & Month(Now),2) & Right("0" & Day(Now),2) & Year(Now)
RunStr = "D:\robocopy d: r: /MIR /r:1 /w:1 /log:d:\backup" & tdate & ".txt" 
Set wshell = CreateObject("WScript.Shell") 
wshell.Run(RunStr)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
merowingerCommented:
Depending on the configure format ;) For me it's . (dot)
Below a formated one :P
Set objShell = CreateObject("Wscript.Shell") 
objShell.Run "robocopy d: r: /MIR /r:1 /w:1 /log:d:\backup" &Replace(Date,"/","") &".txt",0,True

Open in new window

0
Justin EllenbeckerIT DirectorCommented:
Yeah I went with extra variable to allow for MMDDYYYY so on months like this its not 4132010 it will always sort well then. Either way it will do what he wants I jsut noticed his current formatting.
0
tech-Author Commented:
Thanks!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.