Sign in to follow this  
Followers 0
vickerps

Help With Error On Filecopy

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0