Jump to content

FileCoping Problem.


Recommended Posts

FileCopy(@ScriptFullPath & "myfile.exe","C:\Program Files\my folder\",1)

the above line of code suppose to copy the myfile.exe to a folder in program files when its flag set to overwrite if asked.

but it fails why don't know. to check the operation is done successfully or not i check its return values. and it is 0 means unsuccessful

Link to comment
Share on other sites

FileCopy(@ScriptFullPath & "myfile.exe","C:\Program Files\my folder\",1)

the above line of code suppose to copy the myfile.exe to a folder in program files when its flag set to overwrite if asked.

but it fails why don't know. to check the operation is done successfully or not i check its return values. and it is 0 means unsuccessful

FileCopy(@ScriptFullPath & "\" & "myfile.exe","C:\Program Files\my folder\",1)
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Dim $Chk = 2 
$Chk = FileCopy(@ScriptDir & '\' & "MyFile.exe","C:\Program Files\My Folder\",1) 
if $Chk == 0 Then; 1 = success 0 = fail
    MsgBox(0,"Info","Copying Failed")
    Exit
EndIf

i use the above code to determine is my copying process end successfully or not. and i always get the msgbox which means unsuccessful. why don't know yet. ok first the source address or path i use is a variable one while destination path is fixed. and i also verify the source path by using the following test e.g. so i ensure that i am getting the right path or not.

Dim $directory = @ScriptDir & '\' & "MyFile.exe"  or Dim $directory = @ScriptDir & "\" & "MyFile.exe" [same result.]
MsgBox(0,"Info",$directory)
Exit

the result i get is

D:\_temp\_testing\MyFile.exe

which is perfect 4 a source path anyone know what i was doing wrong.

Link to comment
Share on other sites

Hi,

Does the destination directory exist?

Maybe use 8 + 1 for "Create Destination if it doesn't exit" + "Overwrite existing file"

FileCopy(@ScriptDir & "\myfile.exe", @ProgramFilesDir & "\my folder\", 9)

Cheers

Link to comment
Share on other sites

All I can say is I used the line I posted above, I made a file called myfile.exe in the script directory, I run the line above and it works for me.. the file is copied to program files in a folder called my folder, mind you the destination directory didn't exist before I ran the line..

Link to comment
Share on other sites

Dim $Chk = 2 
$Chk = FileCopy(@ScriptDir & '\' & "MyFile.exe","C:\Program Files\My Folder\",1) 
if $Chk == 0 Then; 1 = success 0 = fail
    MsgBox(0,"Info","Copying Failed")
    Exit
EndIf

i use the above code to determine is my copying process end successfully or not. and i always get the msgbox which means unsuccessful. why don't know yet. ok first the source address or path i use is a variable one while destination path is fixed. and i also verify the source path by using the following test e.g. so i ensure that i am getting the right path or not.

Dim $directory = @ScriptDir & '\' & "MyFile.exe"  or Dim $directory = @ScriptDir & "\" & "MyFile.exe" [same result.]
MsgBox(0,"Info",$directory)
Exit

the result i get is

D:\_temp\_testing\MyFile.exe

which is perfect 4 a source path anyone know what i was doing wrong.

Can you manually copy a file to that folder? That is, do you have full write access? Are you running on Vista?
Link to comment
Share on other sites

And MyFile.exe isn't running when you're tring to copy it?

no it is not running. i close using process close and then check process existence before going further forward if it exists script stops so there is no chance that myfile.exe was running. so when file copy code is running it means myfile.exe is closed.

N.B. Here i like to mention one thing as i am using the whole work in virtual environment using VMware + Guest OS is WinXP SP3 in which all the coding and running of the application happen. because it help me to easily restore to a safe point when i messed it up. as far as my knowledge it doesn't have any issue because the whole OS is running in such environment. autoit can pretty easily work too.

Edited by mFm
Link to comment
Share on other sites

no it is not running. i close using process close and then check process existence before going further forward if it exists script stops so there is no chance that myfile.exe was running. so when file copy code is running it means myfile.exe is closed.

N.B. Here i like to mention one thing as i am using the whole work in virtual environment using VMware + Guest OS is WinXP SP3 in which all the coding and running of the application happen. because it help me to easily restore to a safe point when i messed it up. as far as my knowledge it doesn't have any issue because the whole OS is running in such environment. autoit can pretty easily work too.

Well that's it, I'm stumped. :)

Using the code you posted:

Dim $Chk = 2
$Chk = FileCopy(@ScriptDir & '\' & "MyFile.exe","C:\Program Files\My Folder\",1)
if $Chk == 0 Then; 1 = success 0 = fail
    MsgBox(0,"Info","Copying Failed")
    Exit
EndIf

Works fine for me when "C:\Program Files\My Folder" exists and "MyFile.exe" is in the @ScriptDir.

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