Link to home
Start Free TrialLog in
Avatar of Reyesrj
ReyesrjFlag for Guam

asked on

Batch Script .bat

Hi All,

I have a script that when I try to run it, it closes at this point:

1. FOR /f %a IN ('WMIC OS GET LocalDateTime ^| FIND "."') DO SET DTS=%a
2. SET NowStamp=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%_%DTS:~8,2%-%DTS:~10,2%-%DTS:~12,2%
3. robocopy "C:\Users\richa\Google Drive" /MIR F:\1BackUp\GoogleDrive_%NowStamp%

I'm trying to backup my files at 6pm, when I'm gone for the day.  It will create a backup copy and append the current time and date at the end of the folder name.  Each line will run in the command window.  It just won't run if I create a .cmd or .bat script.

Please help with this problem or suggest an alternative solution.

Thank you in advance.

I'm using a windows 10 workstation.
Avatar of NVIT
NVIT
Flag of United States of America image

Change the FOR line to...
FOR /f %%a IN ('WMIC OS GET LocalDateTime ^| FIND "."') DO SET DTS=%%a

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Reyesrj

ASKER

Thank you.  Works Perfect now!
Glad to help.