Borje Posted May 18, 2023 Posted May 18, 2023 (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 May 18, 2023 by Borje Solved
Skeletor Posted May 18, 2023 Posted May 18, 2023 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 RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI
Borje Posted May 18, 2023 Author Posted May 18, 2023 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")
Skeletor Posted May 18, 2023 Posted May 18, 2023 (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 May 18, 2023 by Skeletor Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI
OJBakker Posted May 18, 2023 Posted May 18, 2023 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
Borje Posted May 18, 2023 Author Posted May 18, 2023 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
OJBakker Posted May 18, 2023 Posted May 18, 2023 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.
Borje Posted May 18, 2023 Author Posted May 18, 2023 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?
Danp2 Posted May 18, 2023 Posted May 18, 2023 This should work as long as the folder structure you included in the attachment is correct -- #include "Folder.au3" Local Const $sMessage = "Select Register-Backup folder to restore" Local $Folder = FileSelectFolder2($sMessage, @scriptdir) If Not @error Then Run("Regedit.exe /s " & $Folder & "\RegBackup\RegBackup.reg") EndIf Latest Webdriver UDF Release Webdriver Wiki FAQs
OJBakker Posted May 18, 2023 Posted May 18, 2023 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 Posted May 18, 2023 Author Posted May 18, 2023 Thank all of you helping me all works now with danp2 script many many thanks!!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now