Jump to content

Help With Error On Filecopy


Recommended Posts

How would i write this

I can do it but it messy and lot of repeat coding. I am sure there a easier way

FileCopy ( "D:\utility\Receipt.ini", "C:\windows\Receipt.ini", 1)

FileCopy ( "D:\utility\reset.ini", "C:\windows\reset.ini", 1)

FileCopy ( "D:\utility\logon.cmd", "C:\windows\logon\logon.cmd", 1)

FileCopy ( "D:\utility\NtConfig.pol", "C:\windows\NtConfig.pol", 1)

FileCopy ( "D:\utility\unres.pol", "C:\windows\unres.pol", 1)

If any of the filecopy's fail i want the script to bring a msgbox up saying 'abort' or somthing like that and then exit

Link to comment
Share on other sites

  • Administrators

How would i write this

I can do it but it messy and lot of repeat coding. I am sure there a easier way

                FileCopy ( "D:\utility\Receipt.ini", "C:\windows\Receipt.ini", 1)

FileCopy ( "D:\utility\reset.ini", "C:\windows\reset.ini", 1)

FileCopy ( "D:\utility\logon.cmd", "C:\windows\logon\logon.cmd", 1)

FileCopy ( "D:\utility\NtConfig.pol", "C:\windows\NtConfig.pol", 1)

FileCopy ( "D:\utility\unres.pol", "C:\windows\unres.pol", 1)

If any of the filecopy's fail i want the script to bring a msgbox up saying 'abort' or somthing like that and then exit

$res = 0
$res = $res + FileCopy ( "D:\utility\Receipt.ini", "C:\windows\Receipt.ini", 1)
$res = $res + FileCopy ( "D:\utility\reset.ini", "C:\windows\reset.ini", 1)
$res = $res + FileCopy ( "D:\utility\logon.cmd", "C:\windows\logon\logon.cmd", 1)
$res = $res + FileCopy ( "D:\utility\NtConfig.pol", "C:\windows\NtConfig.pol", 1)
$res = $res + FileCopy ( "D:\utility\unres.pol", "C:\windows\unres.pol", 1)

If $res <> 5 Then
...
error handling code
...
EndIf
Link to comment
Share on other sites

  • Developers

If you want to check every filecopy and stop on failure you could do it with a Function:

FC( "D:\utility\Receipt.ini", "C:\windows\Receipt.ini")
FC( "D:\utility\reset.ini", "C:\windows\reset.ini")
FC( "D:\utility\logon.cmd", "C:\windows\logon\logon.cmd")
FC( "D:\utility\NtConfig.pol", "C:\windows\NtConfig.pol")
FC( "D:\utility\unres.pol", "C:\windows\unres.pol")

Func FC($src,$trg)
   $rc = FileCopy ($src,$trg)
   If $rc then return
   MsgBox(48,"Error","Error copying file:" & $src)
   Exit
EndFunc

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