Jump to content

Recommended Posts

Posted (edited)

Hi I need som help with the selcted date

 

#include "Folder.au3"
Local Const $sMessage = "Select Register-Backup folder to restore"
Local $Folder = FileSelectFolder2($sMessage, @scriptdir)

MsgBox(32+4," Result  ", $Folder) ;4096 ; The selection works

; What I want is how to do to have the selected date replaced to @YEAR & "-" & @MON & "-" & @MDAY in the line below !!

 Run("Regedit.exe /s @ScriptDir" & "\RegBackup" & "-" &@YEAR & "-" & @MON & "-" & @MDAY & "\RegBackup.reg")

 MsgBox(32+4," Result after selecting a folder ", @YEAR & "-" & @MON & "-" & @MDAY) ; This must display the selected date and not today date

 

Folder.zip

Edited by Borje
Solved
Posted

So if I understand you correctly, you want to create a folder with the name "RegBackup" followed by the year, month, and day, and then verify if the folder exists using a MsgBox?
Example below:

Local $folderName = "RegBackup-" & @YEAR & "-" & @MON & "-" & @MDAY
Local $folderPath = @ScriptDir & "\" & $folderName

If Not FileExists($folderPath) Then
    DirCreate($folderPath)
    MsgBox(64 + 4, "Folder Created", "The folder " & $folderName & " has been created.")
Else
    MsgBox(48 + 4, "Folder Exists", "The folder " & $folderName & " already exists.")
EndIf

 

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Posted

No I not want to create the folder is already made but what i want when I open the folder dialog and pick

a already made i want this date to be inserted in line below

 

Run("Regedit.exe /s @ScriptDir" & "\RegBackup" & "-" &@YEAR & "-" & @MON & "-" & @MDAY & "\RegBackup.reg")
Posted (edited)

Like this:
 

Local $folderName = "RegBackup"
Local $newFolderName = $folderName & "-" & @YEAR & "-" & @MON & "-" & @MDAY

Local $folderPath = @ScriptDir & "\" & $folderName
Local $newFolderPath = @ScriptDir & "\" & $newFolderName

If Not FileExists($newFolderPath) Then
    If FileExists($folderPath) Then
        DirMove($folderPath, $newFolderPath)
        MsgBox(52, "Folder Renamed", "The folder has been renamed to: " & $newFolderName)
    Else
        MsgBox(20, "Folder Not Found", "The folder " & $folderName & " does not exist.")
    EndIf
Else
    MsgBox(52, "Folder Exists", "The folder " & $newFolderName & " already exists.")
EndIf


Run("Regedit.exe /s @ScriptDir" & "\" & $newFolderName & "\RegBackup.reg")

 

Edited by Skeletor

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Posted

You have the date already embedded in the name of the folder so you do not need to extract the date-parts to restore the registry or report the date in msgbox.

The code below is probably close to what you want (untested).

#include "Folder.au3"
Local Const $sMessage = "Select Register-Backup folder to restore"
Local $Folder = FileSelectFolder2($sMessage, @ScriptDir)

MsgBox(32 + 4, " Result  ", $Folder) ;4096 ; The selection works

; What I want is how to do to have the selected date replaced to @YEAR & "-" & @MON & "-" & @MDAY in the line below !!

; Run("Regedit.exe /s @ScriptDir" & "\RegBackup" & "-" &@YEAR & "-" & @MON & "-" & @MDAY & "\RegBackup.reg")

; MsgBox(32+4," Result after selecting a folder ", @YEAR & "-" & @MON & "-" & @MDAY) ; This must display the selected date and not today date

; assuming the $Folder is full path to the reg file

If FileExists($Folder & "\RegBackup.reg") Then
    Run("Regedit.exe /s $Folder" & "\RegBackup.reg")
    Local $sDisplayDate = StringReplace($Folder, @ScriptDir & "\RegBackup" & "-", "") ; remove first part, leaving only the date-part
    MsgBox(32 + 4, " Result after selecting a folder ", $sDisplayDate) ; This must display the selected date and not today date
    ; if you want to get the separate parts of the date use stringsplit($sDisplayDate, "-")
EndIf

 

Posted

I can not have that to works the result should be this

 

Run("Regedit.exe /s @ScriptDir" & "\RegBackup" & "-" &@YEAR & "-" & @MON & "-" & @MDAY & "\RegBackup.reg")

The stringreplace should only replace the  @YEAR @MON @DAY all other should be there from the select dialog

So I can run this with Regedit.exe   

Posted

No, it should not!

You want to restore an older backup to the registry.

You select a subfolder in the @scriptdir with in the name of that subfolder the date of the older backup.

You add the name of the registry backup file to the path of the selected folder and that is all that is needed to let regedit do its job.

If you insist you can split the individual date parts from the foldername, but there is no need to do so.

Posted

I want to select a older backup and then run the regiedit with the selected date and not todays date 

perhaps the syntax is wrong in the run regedit?

Posted

Post the code you use to create the backups. There is probably something different between the scripts for creating / restoring backups relating to paths/filenames.

Also check the value of the full filename used in the regedit line. It might be an error with a missing of duplicate "\".

  • Borje changed the title to (solved) Need some help with dates

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...