mFm Posted May 28, 2008 Posted May 28, 2008 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
Andreik Posted May 28, 2008 Posted May 28, 2008 (edited) 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 May 28, 2008 by Andreik
mFm Posted May 29, 2008 Author Posted May 29, 2008 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.
smashly Posted May 29, 2008 Posted May 29, 2008 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
smashly Posted May 29, 2008 Posted May 29, 2008 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..
ResNullius Posted May 29, 2008 Posted May 29, 2008 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?
ResNullius Posted May 29, 2008 Posted May 29, 2008 No i am running WinXP SP3 Can you manually copy a file to that folder? That is, do you have full write access? Are you running on Vista?Can you?
mFm Posted May 29, 2008 Author Posted May 29, 2008 yes i can manually copy the file into the destination folder without any problems.
ResNullius Posted May 29, 2008 Posted May 29, 2008 yes i can manually copy the file into the destination folder without any problems.And MyFile.exe isn't running when you're tring to copy it?
mFm Posted May 29, 2008 Author Posted May 29, 2008 (edited) 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 May 29, 2008 by mFm
ResNullius Posted May 29, 2008 Posted May 29, 2008 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now