Sign in to follow this  
Followers 0
coucou

Advise: FileCopy/FileDelete and @ProgramFilesDir

11 posts in this topic

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

Share this post


Link to post
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!


tolle indicium

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Well, now you know! :P, ill look into your script 'ill be posting back soon.'


tolle indicium

Share this post


Link to post
Share on other sites

Works fine.. just wondering why do you copy it to the same place its in , run it... then delete it?


tolle indicium

Share this post


Link to post
Share on other sites

Its a patch applied to a software in an unattenended installation.

I'm copying the patch, runing it then delting it.

coucou

Share this post


Link to post
Share on other sites

So, why are you copying it to the same exact directy that it's already in?


tolle indicium

Share this post


Link to post
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

Share this post


Link to post
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!

Actually, both are correct spelling. Which you use depends on what you're saying.

"Please advise."

"I need advice."

Share this post


Link to post
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.

Share this post


Link to post
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

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