Jump to content

Advise: FileCopy/FileDelete and @ProgramFilesDir


coucou
 Share

Recommended Posts

Hi,

Here bellow a script using FileCopy/FileDelete and @ProgramFilesDir checked working.

FileCopy("source_file.exe", @ProgramFilesDir & '\dest_folder\')
Run('"' & @ProgramFilesDir & '\dest_folder\source_file.exe"')
FileDelete(@ProgramFilesDir & '\dest_folder\source_file.exe')

Although, FileCopy and FileDelete functions works, are the script strictly correct?

why there are more quotation marks for the Run function???

Regards

coucou

Link to comment
Share on other sites

This really doesn't have anything to do with your script, but i think "Advise" is spelled " Advice " :P, just trying to help!

Sorry for my poor english.

English, is not my mother tongue and i always confuse between an advice and to advise

Regards

coucou

Edited by coucou
Link to comment
Share on other sites

Here bellow a script using FileCopy/FileDelete and @ProgramFilesDir checked working.

FileCopy("source_file.exe", @ProgramFilesDir & '\dest_folder\')
Run('"' & @ProgramFilesDir & '\dest_folder\source_file.exe"')
FileDelete(@ProgramFilesDir & '\dest_folder\source_file.exe')

Although, FileCopy and FileDelete functions works, are the script strictly correct?

why there are more quotation marks for the Run function???

It would seem that you are trying to delete a running process that is started by Run so the process exits very fast? The extra quotes around the Run parameter is fine as it prevents any spaces causing issue of finding the file. I have yet to notice any need to use extra quotes around any File* functions.

:P

Link to comment
Share on other sites

Hi,

Here bellow a script using FileCopy/FileDelete and @ProgramFilesDir checked working.

FileCopy("source_file.exe", @ProgramFilesDir & '\dest_folder\')
Run('"' & @ProgramFilesDir & '\dest_folder\source_file.exe"')
FileDelete(@ProgramFilesDir & '\dest_folder\source_file.exe')

Although, FileCopy and FileDelete functions works, are the script strictly correct?

why there are more quotation marks for the Run function???

Regards

coucou

Somewhere along the line your original question seems to have gotten lost in the translation (pun intended!).

The reason you need double quotes passed for the RUN command is because the string passed is literally run, and if there are any spaces in the path the line will be misinterpreted without the entire path being quoted.

Now this might confuse you even more because I learned earlier this year that apparently in some non US versions of Windows @ProgramFilesDir equates to C:\Programs. However, the US version of Windows @ProgramFilesDir equates to C:\Program Files (although it sounds like this may not be your setup)

Thus, if the line in your script was

Run( @ProgramFilesDir & '\dest_folder\source_file.exe')

What would be run is C:\Program with the parameter Files\dest_folder\source_file.exe

The FileCopy and FileDelete functions are being passed parameters for which the entire string is used regardless of spaces, so they understand that @ProgramFilesDir & '\dest_folder\source_file.exe' means everything in the string including the spaces.

This is also the reason I use single quotes almost exclusively (except if I need a ' within the text) as it makes using double quotes a lot easier.

Hope that helps.

Link to comment
Share on other sites

Hi all,

Soryy for the delay, I tried replying since Friday but coldn't connect to AutoIt forum.

TNX Everybody for yr enlighten...

It would seem that you are trying to delete a running process that is started by Run so the process exits very fast? The extra quotes around the Run parameter is fine as it prevents any spaces causing issue of finding the file. I have yet to notice any need to use extra quotes around any File* functions.

:P

In fact, these 3 lines will be inserted in Cyberlink MediaShow script.

Instead of extracting the MedShow_Patch1 to c:\Program Files\Cyberlink, i'm copying it to. Then i run this patch and when its finish updating MediaShow, i'm deleting it.

Regards

coucou

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