Jump to content
Sign in to follow this  
mFm

FileCoping Problem.

Recommended Posts

mFm

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

Share this post


Link to post
Share on other sites
Andreik

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

Share this post


Link to post
Share on other sites
mFm

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.

Share this post


Link to post
Share on other sites
smashly

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

Share this post


Link to post
Share on other sites
smashly

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

Share this post


Link to post
Share on other sites
ResNullius

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?

Share this post


Link to post
Share on other sites
ResNullius

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?

Share this post


Link to post
Share on other sites
mFm

yes i can manually copy the file into the destination folder without any problems.

Share this post


Link to post
Share on other sites
ResNullius

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?

Share this post


Link to post
Share on other sites
mFm

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

Share this post


Link to post
Share on other sites
ResNullius

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.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.