Jump to content

Recommended Posts

Posted (edited)

Good day,

So, I have the following script:

; -----------------------------------------------
#include <AutoItConstants.au3>
#include <FileConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; -----------------------------------------------
BackupRMLData()
; -----------------------------------------------
Func BackupRMLData()
    Local $iStart = 4, $iEnd = 3
    Local $sSrcPath[$iStart] = [$iEnd]
    $sSrcPath[1] = "C:\RML"
    $sSrcPath[2] = "C:\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Software Audio Console"
    $sSrcPath[3] = "C:\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\SAWStudio64"
    ; -----------------
    Local $sDstPath[$iStart] = [$iEnd]
    $sDstPath[1] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC"
    $sDstPath[2] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"
    $sDstPath[3] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"
    ; -----------------------------------------------
    Local $sMessage = "Backup data..." & @CRLF & @CRLF
    ; -----------------------------------------------
    For $i = 1 To $sSrcPath[0]
        Local $sResult = DirMove($sSrcPath[$i], $sDstPath[$i], $FC_OVERWRITE)
        Switch $sResult
            Case 0
                $sResult = "The data WAS NOT backed-up successfully!"
            Case 1
                $sResult = "The data WAS backed-up successfully!"
        EndSwitch
        ; -----------------
        $sMessage &= $sResult & @CRLF
    Next
    ; -----------------------------------------------
    $sMessage &= @CRLF & "The Backup of data completed..." & @CRLF
    ; -----------------------------------------------
    SplashTextOn("NOTICE!!", $sMessage, 450, 165, -1, -1, 4, "FuturaBQ-DemiBold", 12)
    Sleep(2500)
    SplashOff()
    ; -----------------------------------------------
EndFunc   ;==>BackupRMLData
; -----------------------------------------------

What I getting is the following:

sample_a.png

A: The SAWStudio64 folder is copying just fine [A].
B: The three links should be contained within a "Software Audio Console" folder...but are not...as shown in .

What am I doing WRONG?!?

 

Edited by mr-es335
Posted

confirm that the shortcuts are located in
"C:\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Software Audio Console" and not e.g. in
"C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Software Audio Console"

or in some other path

I know that I know nothing

Posted (edited)

ioa747,

Part 1
Start Menu Folders|Links are always stored in one of two locations - regardless of the Windows version:

1) C:\ProgramData\Microsoft\Windows\Start Menu\Programs
2) C:\Users\[UserName]l\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

In my particular situation, I always manually copy the data paths - to ensure that I am sending|receiving the data in the correct location(s).

At C:\ProgramData\Microsoft\Windows\Start Menu\Programs - there are no folders located.
At C\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs - there are two folders, namely, SAWStudio64 and Software Audio Console.

Thus, my source data paths are indeed correct!

Part 2
What is particularly interesting, when I reorganize the script...for example [ I have simply flipped the last two source commands].
The first one has the folder created - but not the second!

$sSrcPath[1] = "C:\RML"
$sSrcPath[2] = "C:\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\SAWStudio64" ; Folder and links are copied!
$sSrcPath[3] = "C:\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Software Audio Console" ; Only the links are copied!
; ...compared to...

$sSrcPath[1] = "C:\RML"
$sSrcPath[2] = "C:\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Software Audio Console" ; Folder and links are copied!
$sSrcPath[3] = "C:\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\SAWStudio64" ; Only the links are copied!

; ...the destination location...in both cases...is the same...

$sDstPath[2] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"
$sDstPath[3] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"

Part 3
If I create the complete destination folder path in the destination folder, then all works as it should!

Edited by mr-es335
Posted (edited)

look at the shortcut files inside the folders, if they have Read-Only Attrib

Edited by ioa747

I know that I know nothing

Posted (edited)

No...they do not...

DUH!! Would this happen to be the reason "Why?"

; Existing
$sDstPath[2] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"
$sDstPath[3] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"

; Updated...added the actual destination folders!!!
$sDstPath[2] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\SAWStudio64"
$sDstPath[3] = "D:\Install\App_Install\Digital_Audio\1_RML_Labs\Data\SourceDataC\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Software Audio Console"

If so, I am seriously experiencing from a server case of "cranial deprivation"...or that I am simply an "ID-10-T"!

Hmmmm....

Update!!
Just tested it out...and "Yeppers!" That did the trick! [Click_Me]

Edited by mr-es335
Posted

DirMove and DirCopy are different in usage, try to understand it.

Here is an example script for backing up and restoring folders:

#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <FileConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; -----------------------------------------------

; ------------------------------------------------------------- INPUT :
Global Const $sUserName = @UserName
Global $sNAME_Path[6]
$sNAME_Path[0] = 4
$sNAME_Path[1] = 'SAC64' ; App Folder Name
$sNAME_Path[2] = 'Software Audio Console64' ; Start Menu Folder Name
$sNAME_Path[3] = 'SAWStudio' ; App Folder Name
$sNAME_Path[4] = 'SAWStudio' ; Start Menu Folder Name
$sNAME_Path[5] = 'RML' ; App Data Folder Name
Global Const $aDirNAME_Path = $sNAME_Path
Global Const $sORGAPP_Path = @HomeDrive
Global Const $sBACKUP_Path = "D:\Backup"
Global Const $sPathDir_BACKUP_Data = $sBACKUP_Path & "\Data"
Global Const $sPathDir_BACKUP_App = $sBACKUP_Path & "\Apps"
Global Const $sPathDir_BACKUP_Start_Menu = $sBACKUP_Path & "\Start_Menu"
Global Const $iSleep_Time = 2500 ; ms Stop Show Result
; ----------------------------------------------------------------------
Global Const $sPathDir_ORG_StartMenuPrograms = @HomeDrive & "\Users\" & $sUserName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs" ; @AppDataDir & "\Microsoft\Windows\Start Menu\Programs"
Global $sPathDir_ORG[6]
$sPathDir_ORG[0] = 5
$sPathDir_ORG[1] = $sORGAPP_Path & "\" & $aDirNAME_Path[1]
$sPathDir_ORG[2] = $sPathDir_ORG_StartMenuPrograms & '\' & $aDirNAME_Path[2]
$sPathDir_ORG[3] = $sORGAPP_Path & "\" & $aDirNAME_Path[3]
$sPathDir_ORG[4] = $sPathDir_ORG_StartMenuPrograms & '\' & $aDirNAME_Path[4]
$sPathDir_ORG[5] = $sPathDir_ORG_StartMenuPrograms & '\' & $aDirNAME_Path[5]
Global Const $aPathDir_ORG = $sPathDir_ORG
; ----------------------------------------------------------------------
Global $sPathDir_BACKUP[6]
$sPathDir_BACKUP[0] = 5
$sPathDir_BACKUP[1] = $sPathDir_BACKUP_App & "\" & $aDirNAME_Path[1]
$sPathDir_BACKUP[2] = $sPathDir_BACKUP_Start_Menu & "\" & $aDirNAME_Path[2]
$sPathDir_BACKUP[3] = $sPathDir_BACKUP_App & "\" & $aDirNAME_Path[3]
$sPathDir_BACKUP[4] = $sPathDir_BACKUP_Start_Menu & "\" & $aDirNAME_Path[4]
$sPathDir_BACKUP[5] = $sPathDir_BACKUP_Data & "\" & $aDirNAME_Path[5]
Global Const $aPathDir_BACKUP = $sPathDir_BACKUP
; ----------------------------------------------------------------------


_Remove_RMLData_Backup()
_Backup_RMLData()
;_Remove_RMLData_AppDir()
;_Restore_RMLData()


; -----------------------------------------------
Func _Backup_RMLData()
    ; -----------------------------------------------
    Local $sResult, $iResult = 0, $sMessage = "Backup data..." & @CRLF & @CRLF
    ; -----------------------------------------------
    For $i = 1 To $aPathDir_ORG[0]
        ToolTip('> COPY: ' & $aPathDir_ORG[$i] & ' -> TO: ' & $aPathDir_BACKUP[$i], (@DesktopWidth / 2) - 50, 5, 'Backing up data [' & $i & '/' & $aPathDir_ORG[0] & '] please wait...')
        ConsoleWrite('> COPY: ' & $aPathDir_ORG[$i] & ' (FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF)
        ConsoleWrite('- TO: ' & $aPathDir_BACKUP[$i] & ' (FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF)
        ConsoleWrite('! Please wait: Copying ....' & @CRLF)
        If Not FileExists($aPathDir_BACKUP[$i]) Then DirCreate($aPathDir_BACKUP[$i])
        If FileExists($aPathDir_ORG[$i]) Then
            $sResult = DirCopy($aPathDir_ORG[$i], $aPathDir_BACKUP[$i], $FC_OVERWRITE)
        Else
            $sResult = 0
        EndIf
        Switch $sResult
            Case 0
                ConsoleWrite('!> Result (0): ERROR: Data was not backed-up! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF)
                $sResult = "[" & $aDirNAME_Path[$i] & "] ERROR: Data was not backed up"
            Case 1
                $iResult += 1
                ConsoleWrite('-> Result (1): The data WAS backed-up successfully! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF)
                $sResult = "[" & $aDirNAME_Path[$i] & "] The data WAS backed-up successfully!"
        EndSwitch
        ; -----------------
        $sMessage &= $sResult & @CRLF
        $sResult = ''
        ToolTip('')
    Next
    ToolTip('')
    ; -----------------------------------------------
    $sMessage &= @CRLF & "The Backup of data completed..." & @CRLF
    ; -----------------------------------------------
    ToolTip($sMessage, (@DesktopWidth / 2) - 50, 5, "NOTICE!!", 1)
    Sleep($iSleep_Time)
    ToolTip('')
    $sResult = $aPathDir_ORG[0] - $iResult
    If ($sResult < 1) Then
        ConsoleWrite('+> The data WAS backed-up successfully!' & @CRLF)
        Return True
    Else
        ConsoleWrite('!> ERROR: Data was not backed-up!' & @CRLF)
        Return False
    EndIf
    ; -----------------------------------------------
EndFunc   ;==>_Backup_RMLData
; -----------------------------------------------
Func _Restore_RMLData()
    ; -----------------------------------------------
    Local $sResult, $iResult = 0, $sMessage = "Restore data..." & @CRLF & @CRLF
    ; -----------------------------------------------
    For $i = 1 To $aPathDir_BACKUP[0]
        ToolTip('> COPY: ' & $aPathDir_BACKUP[$i] & ' -> TO: ' & $aPathDir_ORG[$i], (@DesktopWidth / 2) - 50, 5, 'Restoring data [' & $i & '/' & $aPathDir_BACKUP[0] & '] please wait...')
        ConsoleWrite('- COPY: ' & $aPathDir_BACKUP[$i] & ' (FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF)
        ConsoleWrite('> TO: ' & $aPathDir_ORG[$i] & ' (FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF)
        ConsoleWrite('! Please wait: Copying ....' & @CRLF)
        If Not FileExists($aPathDir_ORG[$i]) Then DirCreate($aPathDir_ORG[$i])
        If FileExists($aPathDir_BACKUP[$i]) Then
            $sResult = DirCopy($aPathDir_BACKUP[$i], $aPathDir_ORG[$i], $FC_OVERWRITE)
        Else
            $sResult = 0
        EndIf
        Switch $sResult
            Case 0
                ConsoleWrite('+> Result (0): ERROR: Data not restored! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF)
                $sResult = "[" & $aDirNAME_Path[$i] & "] ERROR: Data not restored!"
            Case 1
                $iResult += 1
                ConsoleWrite('+> Result (1): Data restored successfully! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF)
                $sResult = "[" & $aDirNAME_Path[$i] & "] Data restored successfully!"
        EndSwitch
        ; -----------------
        $sMessage &= $sResult & @CRLF
        $sResult = ''
        ToolTip('')
    Next
    ToolTip('')
    ; -----------------------------------------------
    $sMessage &= @CRLF & "Data recovery completed." & @CRLF
    ; -----------------------------------------------
    ToolTip($sMessage, (@DesktopWidth / 2) - 50, 5, "NOTICE!!", 1)
    Sleep($iSleep_Time)
    ToolTip('')
    $sResult = $aPathDir_ORG[0] - $iResult
    If ($sResult < 1) Then
        ConsoleWrite('+> Data restored successfully!' & @CRLF)
        Return True
    Else
        ConsoleWrite('!> ERROR: Data not restored!' & @CRLF)
        Return False
    EndIf
EndFunc   ;==>_Restore_RMLData
; -----------------------------------------------
Func _Remove_RMLData_Backup()
    ; -----------------------------------------------
    Local $sResult, $iResult = 0, $sMessage = "Remove  data..." & @CRLF & @CRLF
    ; -----------------------------------------------
    For $i = 1 To $aPathDir_BACKUP[0]
        ToolTip('>  Remove: ' & $aPathDir_BACKUP[$i], (@DesktopWidth / 2) - 50, 5, 'Removing data [' & $i & '/' & $aPathDir_BACKUP[0] & '] please wait...')
        ConsoleWrite('! Remove: ' & $aPathDir_BACKUP[$i] & ' (FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF)
        ConsoleWrite('- Please wait: removing...' & @CRLF)
        If FileExists($aPathDir_BACKUP[$i]) Then
            $sResult = DirRemove($aPathDir_BACKUP[$i], $DIR_REMOVE)
        Else
            $sResult = 1
        EndIf
        Switch $sResult
            Case 0
                ConsoleWrite('+> Result (0): ERROR: Data not Removed! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF)
                $sResult = "[" & $aDirNAME_Path[$i] & "] ERROR: Data not Removed!"
            Case 1
                $iResult += 1
                ConsoleWrite('+> Result (1): Data Removed successfully! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF)
                $sResult = "[" & $aDirNAME_Path[$i] & "] Data Removed successfully!"
        EndSwitch
        ; -----------------
        $sMessage &= $sResult & @CRLF
        $sResult = ''
        ToolTip('')
    Next

    ToolTip('')
    ; -----------------------------------------------
    $sMessage &= @CRLF & "Data Removal Completed." & @CRLF
    ; -----------------------------------------------
    ToolTip($sMessage, (@DesktopWidth / 2) - 50, 5, "NOTICE!!", 1)
    Sleep($iSleep_Time)
    ToolTip('')
    $sResult = $aPathDir_ORG[0] - $iResult
    If ($sResult < 1) Then
        ConsoleWrite('+> Data Removed successfully!' & @CRLF)
        Return True
    Else
        ConsoleWrite('!> ERROR: Data not Removed!' & @CRLF)
        Return False
    EndIf
EndFunc   ;==>_Remove_RMLData_Backup
; -----------------------------------------------
Func _Remove_RMLData_AppDir()
    ; -----------------------------------------------
    Local $sResult, $iResult = 0, $sMessage = "Remove  data..." & @CRLF & @CRLF
    ; -----------------------------------------------
    For $i = 1 To $aPathDir_ORG[0]
        ToolTip('>  Remove: ' & $aPathDir_ORG[$i], (@DesktopWidth / 2) - 50, 5, 'Removing data [' & $i & '/' & $aPathDir_ORG[0] & '] please wait...')
        ConsoleWrite('!> Remove: ' & $aPathDir_ORG[$i] & ' (FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF)
        ConsoleWrite('- Please wait: removing ....' & @CRLF)
        If FileExists($aPathDir_ORG[$i]) Then
            $sResult = DirRemove($aPathDir_ORG[$i], $DIR_REMOVE)
        Else
            $sResult = 1
        EndIf
        Switch $sResult
            Case 0
                ConsoleWrite('+> Result (0): ERROR: Data not Removed! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF)
                $sResult = "[" & $aDirNAME_Path[$i] & "] ERROR: Data not Removed!"
            Case 1
                $iResult += 1
                ConsoleWrite('+> Result (1): Data Removed successfully! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF)
                $sResult = "[" & $aDirNAME_Path[$i] & "] Data Removed successfully!"
        EndSwitch
        ; -----------------
        $sMessage &= $sResult & @CRLF
        $sResult = ''
        ToolTip('')
    Next
    ToolTip('')
    ; -----------------------------------------------
    $sMessage &= @CRLF & "Data Removal Completed." & @CRLF
    ; -----------------------------------------------
    ToolTip($sMessage, (@DesktopWidth / 2) - 50, 5, "NOTICE!!", 1)
    Sleep($iSleep_Time)
    ToolTip('')
    $sResult = $aPathDir_ORG[0] - $iResult
    If ($sResult < 1) Then
        ConsoleWrite('+> Data Removed successfully!' & @CRLF)
        Return True
    Else
        ConsoleWrite('!> ERROR: Data not Removed!' & @CRLF)
        Return False
    EndIf
EndFunc   ;==>_Remove_RMLData_AppDir
; -----------------------------------------------

 

Regards,
 

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...