Results 1 to 13 of 13
  1. #1
    Star Lounger GiddyUpGo's Avatar
    Join Date
    Nov 2009
    Location
    Clarksville, Arkansas USA
    Posts
    99
    Thanks
    44
    Thanked 4 Times in 3 Posts

    Need this batch file to save with the date and time

    This Basic batch file works for me, except it over writes the prev saves.

    I need the extra code to make it save with the date and time.

    I have shown only the Basic batch file so someone could start fresh to add the working code.

    I cannot get the

    REGEDIT.exe /E "E:\W7 Computer Backups\MailwasherPro\RegBack\MailWasher.reg" "HKEY_CURRENT_USER\Software\firetrust"

    line to save with the date and time.

    This line saves the Mailwasher Windows w7 Registry entries to a .reg file.

    This batch file backs up my Mailwasher Pro. program. __________________________________________________ ______________
    rmdir "E:\W7 Computer Backups\MailwasherPro\Doc" /s /q

    mkdir "E:\W7 Computer Backups\MailwasherPro\Doc"

    xcopy "C:\Users\Lawrence E. Richards\AppData\Roaming\Mailwasherpro\*.*" "E:\W7 Computer Backups\MailwasherPro\Doc" /S /E /I /H /R /K /O /X /Y /F

    rmdir "E:\W7 Computer Backups\MailwasherPro\PRO" /s /q

    mkdir "E:\W7 Computer Backups\MailwasherPro\PRO"

    xcopy "f:\MailWasher Pro\*.*" "E:\W7 Computer Backups\MailwasherPro\PRO" /S /E /I /H /R /K /O /X /Y /F

    rmdir "E:\W7 Computer Backups\MailwasherPro\RegBack" /s /q

    mkdir "E:\W7 Computer Backups\MailwasherPro\RegBack"

    REGEDIT.exe /E "E:\W7 Computer Backups\MailwasherPro\RegBack\MailWasher.reg" "HKEY_CURRENT_USER\Software\firetrust"

    __________________________________________________ __________________________________________________ _____________________

    Thank you for any help!
    Last edited by GiddyUpGo; 2016-02-25 at 19:46. Reason: The pasted batch file did not display so anyone could read it.
    GiddyUpGo "Don't look back. That is not the direction you are going!"

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    I'm not sure what you mean by
    "I cannot get the
    REGEDIT.exe /E "E:\W7 Computer Backups\MailwasherPro\RegBack\MailWasher.reg" "HKEY_CURRENT_USER\Software\firetrust"
    line to save with the date and time."
    .

    Where do you want this "date and time" to be saved? Somewhere in the registry? In the .REG file? In a log file?

    I'm guessing that you want to add the date and time to the bottom of the reg file, with a semicolon at the front to make it a .reg file comment. Something like:
    Code:
    echo ; %date% %time% >> "E:\W7 Computer Backups\MailwasherPro\RegBack\MailWasher.reg"
    but the format of the date and time may not be what you want.
    It has to be at the bottom of the .reg file, since your REGEDIT command would wipe it out by the save if initially added to the top!
    Last edited by BATcher; 2016-02-26 at 00:51.
    BATcher

    Time prevents everything happening all at once...

  3. The Following User Says Thank You to BATcher For This Useful Post:

    GiddyUpGo (2016-02-26)

  4. #3
    Star Lounger GiddyUpGo's Avatar
    Join Date
    Nov 2009
    Location
    Clarksville, Arkansas USA
    Posts
    99
    Thanks
    44
    Thanked 4 Times in 3 Posts
    What I wish for is that with added code, my batch file would be able to save all lines to a single directory or file dated with the date and time. This file then could be used to select from it's date and time and then ran to restore Mailwasher. I can write code to do this for all my commands except for the Regedit command. It will not be shown nor saved with the rest of the lines. My below code works except for the Regedit command.

    FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
    FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
    FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
    FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
    Set time=
    Set date=
    SET time=%time: =0%
    SET date="%date:~0,2%-%date:~3,2%-%date:~6,6%_%time:~0,2%-%time:~3,2%"

    mkdir "E:\W7 Computer Backups\------"\%date%
    GiddyUpGo "Don't look back. That is not the direction you are going!"

  5. #4
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    That's fairly straightfoward, now you've said what you want, which is the date/time as mm-dd-yyyy_hh-mm
    (I would recommend yyyy-mm-dd_hh-mm for the logical progression towards smaller 'time' values.)

    My problem is I'm not exactly sure what is the format in the US of the %date% variable (is it [m]m/dd/yyyy where the m field is 1 thru 12, without a leading zero?), nor the %time% variable (I thought it included AM or PM)

    For the UK, where the formats are respectively dd/mm/yyyy and [h]h:mm:ss.cs, the following
    Code:
    for /f "tokens=1-5 delims=/;:." %%a in ("%date%;%time: =0%") do set dt=%%c-%%b-%%a_%%d-%%e
    gives yyyy-mm-dd_hh-mm

    Your MKDIR would then be
    Code:
    md "E:\W7 Computer Backups\------\%dt%"
    . Note the placement of the second double-quote...

    See how close that is to what you want.
    Last edited by BATcher; 2016-02-26 at 10:06. Reason: Misplaced hyphen!
    BATcher

    Time prevents everything happening all at once...

  6. The Following User Says Thank You to BATcher For This Useful Post:

    GiddyUpGo (2016-02-26)

  7. #5
    Star Lounger GiddyUpGo's Avatar
    Join Date
    Nov 2009
    Location
    Clarksville, Arkansas USA
    Posts
    99
    Thanks
    44
    Thanked 4 Times in 3 Posts
    Thank you Batcher for your help!
    I have no problems with this code. It gives the date and time as 02-26-2016_10-25 for the directory title.
    The code works perfect in the USA with all of my commands except for the
    REGEDIT.exe /E "E:\W7 Computer Backups\MailwasherPro\RegBack\MailWasher.reg" "HKEY_CURRENT_USER\Software\firetrust"
    command.
    I can find no way for the regedit command to work with my code. It will not create nor save the Mailwasher.REG file in the directory with the other saved command directories and their sub-directories.
    The regedit command works perfect by itself. I just cannot get it to save to the date and time directories with the other commands.

    Note:
    the first part
    REGEDIT.exe /E "E:\W7 Computer Backups\MailwasherPro\RegBack\MailWasher.reg"
    works in making the directory for the .reg file.
    the last part copies the data from the registry to the .reg file.
    "HKEY_CURRENT_USER\Software\firetrust"

    I am sorry that I cannot make it more clear what I wish for.

    I like your changes for my code and will try them out!
    It may not be possible for the regedit command to work under the commands of the date and time code.
    GiddyUpGo "Don't look back. That is not the direction you are going!"

  8. #6
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    If you can't get REGEDIT /E to work the way you want, perhaps you could try REG EXPORT ?
    BATcher

    Time prevents everything happening all at once...

  9. The Following User Says Thank You to BATcher For This Useful Post:

    GiddyUpGo (2016-02-26)

  10. #7
    Star Lounger GiddyUpGo's Avatar
    Join Date
    Nov 2009
    Location
    Clarksville, Arkansas USA
    Posts
    99
    Thanks
    44
    Thanked 4 Times in 3 Posts
    Thank you BATcher for sticking with me.
    Yep! Reg Export might work.
    I never though of this one. I shall work with this one.
    GiddyUpGo "Don't look back. That is not the direction you are going!"

  11. #8
    Star Lounger GiddyUpGo's Avatar
    Join Date
    Nov 2009
    Location
    Clarksville, Arkansas USA
    Posts
    99
    Thanks
    44
    Thanked 4 Times in 3 Posts
    No joy. This will also create the directory with the date and time, but the directory will be empty without the mailwasher.reg file. The command ran by itself works perfect.

    below my commands:

    mkdir "E:\W7 Computer Backups\MailwasherPro\RegBack"\%date%

    reg export "HKEY_CURRENT_USER\Software\firetrust" "E:\W7 Computer Backups\MailwasherPro\RegBack\MailWasher.reg"\%dat e%
    GiddyUpGo "Don't look back. That is not the direction you are going!"

  12. #9
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    I've just set up a BATch file as follows:
    Code:
    for /f "tokens=1-5 delims=/;:." %%a in ("%date%;%time: =0%") do set dt=%%c-%%b-%%a_%%d-%%e
    md "D:\W7 Computer Backups\MailwasherPro\RegBack_%dt%"
    reg export HKLM\Software\7-zip "D:\W7 Computer Backups\MailwasherPro\RegBack_%dt%\7-Zip.reg"
    works to give this
    Code:
     Directory of D:\w7 computer backups
    
    26/02/2016  21:14    <DIR>          .
    26/02/2016  21:14    <DIR>          ..
    26/02/2016  21:14    <DIR>          MailwasherPro
                   0 File(s)              0 bytes
    
     Directory of D:\w7 computer backups\MailwasherPro
    
    26/02/2016  21:14    <DIR>          .
    26/02/2016  21:14    <DIR>          ..
    26/02/2016  21:14    <DIR>          RegBack_2016-02-26_21-14
                   0 File(s)              0 bytes
    
     Directory of D:\w7 computer backups\MailwasherPro\RegBack_2016-02-26_21-14
    
    26/02/2016  21:14    <DIR>          .
    26/02/2016  21:14    <DIR>          ..
    26/02/2016  21:14               328 7-Zip.reg
                   1 File(s)            328 bytes
    Is that nearly what you wanted?
    Last edited by BATcher; 2016-02-26 at 16:20.
    BATcher

    Time prevents everything happening all at once...

  13. The Following User Says Thank You to BATcher For This Useful Post:

    GiddyUpGo (2016-02-26)

  14. #10
    Star Lounger GiddyUpGo's Avatar
    Join Date
    Nov 2009
    Location
    Clarksville, Arkansas USA
    Posts
    99
    Thanks
    44
    Thanked 4 Times in 3 Posts
    You did it!!!! THIS WORKS for the registry file download!
    I modified your file to be mine:

    for /f "tokens=1-5 delims=/;:." %%a in ("%date%;%time: =0%") do set dt=%%c-%%b-%%a_%%d-%%e
    md "E:\W7 Computer Backups\MailwasherPro\RegBack_%dt%"
    reg export "HKEY_CURRENT_USER\Software\firetrust" "E:\W7 Computer Backups\MailwasherPro\RegBack_%dt%\Mailwasher.reg"


    I need these two commands added to it. Would you add them to the above code? I do not wise to mess up your code.

    mkdir "E:\W7 Computer Backups\MailwasherPro\Doc"

    xcopy "C:\Users\Lawrence E. Richards\AppData\Roaming\Mailwasherpro\*.*" "E:\W7 Computer Backups\MailwasherPro\Doc" /S /E /I /H /R /K /O /X /Y /F

    and this one:

    mkdir "E:\W7 Computer Backups\MailwasherPro\PRO"

    xcopy "f:\MailWasher Pro\*.*" "E:\W7 Computer Backups\MailwasherPro\PRO" /S /E /I /H /R /K /O /X /Y /F
    GiddyUpGo "Don't look back. That is not the direction you are going!"

  15. #11
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    I'm not quite sure what you want me to do!
    Are those two sets of MD/XCOPY commands complete in themselves, or do you want to include date and time somewhere in the folder names?

    I would say that I've never seen so many switches in an XCOPY command before!
    BATcher

    Time prevents everything happening all at once...

  16. #12
    Star Lounger GiddyUpGo's Avatar
    Join Date
    Nov 2009
    Location
    Clarksville, Arkansas USA
    Posts
    99
    Thanks
    44
    Thanked 4 Times in 3 Posts
    Yes the two sets of command are complete. I have added them to your code.
    I have set up my batch file and it now works will all the settings I wanted, thanks to you for your help.
    I was about to believe it could not be done, but you did it!
    Have a good day!
    GiddyUpGo "Don't look back. That is not the direction you are going!"

  17. #13
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    I'm pleased that you ended up with what you wanted!
    BATcher

    Time prevents everything happening all at once...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •