Jump to content

need help with this simple script


Recommended Posts

#include <File.au3>
Dim $file,$backupfile,$backupfilename,$trash
For $i=1 To $CmdLine[0]
    $file = $file & " " & $CmdLine[$i]
Next
If $file = "" Then exit
$path = _PathSplit ($file, $trash, $trash, $trash, $trash)
$backupfile = _TempFile (@HomeDrive & "\BACKUP\", "", $path[4])
$filename = $path[3] & $path[4]
If FileCopy ( $file, $backupfile ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup failed to copy "&$file&" to "&$backupfile&".")
    Exit
EndIf
$backupfilename = _PathSplit ($backupfile, $trash, $trash, $trash, $trash)
$backupfilename = $backupfilename[3] & $backupfilename[4]
If IniWrite ( @HomeDrive & "\BACKUP\settings.ini", "Files", $backupfilename, $file ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup could not write to the settings.ini file because it is read-only. Backup h_
as failed.")
    FileDelete ( $backupfile )
    Exit
EndIf
MsgBox (64, "AutoBackup File Backup Utility", "AutoBackup has successfully added "&$filename&" to your weekly backup. Please note that _
the file has not actually been backed up yet, only added to your computer's backup directory. This file, along with the rest of your bac_
kup directory, will be backed up at the designated automatic backup day.")

I run the program (compiled) with this parameter:

C:\Documents and Settings\Matt Roth\My Documents\TChelp\favicon.bmp

And I get:

AutoBackup has failed to copy C:\Documents and Settings\Matt Roth\My Documents\TChelp\favicon.bmp to C:\BACKUP\lkmhuxh.bmp

1. Why would it fail?

???

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • Developers

2. Why on earth is it trying to copy to the Temp dir when I specifically told _TempFile to put it in @HomeDrice & "\BACKUP\"

???

2. _TempFile can change the target directory when the specified directory doesn't exist.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

ok, I fixed that.

#include <File.au3>
Dim $file,$backupfile,$backupfilename,$trash
For $i=1 To $CmdLine[0]
    $file = $file & " " & $CmdLine[$i]
Next
If $file = "" Then exit
$path = _PathSplit ($file, $trash, $trash, $trash, $trash)
$backupfile = _TempFile (@HomeDrive & "\BACKUP\", "", $path[4])
$filename = $path[3] & $path[4]
If FileCopy ( $file, @TempDir & "\BACKUP\", 9 ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup failed to copy "&$file&" to "&@TempDir & "\BACKUP\" & $filename&".")
    Exit
EndIf
$backupfilename = _PathSplit ($backupfile, $trash, $trash, $trash, $trash)
$backupfilename = $backupfilename[3] & $backupfilename[4]
If FileMove ( @TempDir & "\BACKUP\" & $filename, $backupfile ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup failed to move " & @TempDir & "\BACKUP\" & $filename & " to "_
    & $backupfile & ".")
    exit
EndIf
If IniWrite ( @HomeDrive & "\BACKUP\settings.ini", "Files", $backupfilename, $file ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup could not write to the settings.ini file because it is read-only. Backup h_
as failed.")
    FileDelete ( $backupfile )
    Exit
EndIf
MsgBox (64, "AutoBackup File Backup Utility", "AutoBackup has successfully added "&$filename&" to your weekly backup. Please note that _
the file has not actually been backed up yet, only added to your computer's backup directory. This file, along with the rest of your bac_
kup directory, will be backed up at the designated automatic backup day.")

run compiled version with same parameter.

AutoBackup failed to copy C:\Documents and Settings\Matt Roth\My Documents\TChelp\favicon.bmp to C:\DOCUME~1\MATTRO~1\LOCALS~1\Temp\BACKUP\favicon.bmp

why is it doing this?

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • Developers

I see you changed the Filecopy.

Can you try ?:

If FileCopy ( $file, @TempDir & "\BACKUP\" & $filename, 9 ) = 0 Then

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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