Jump to content

Copy/Move/Rename embedded file?


Recommended Posts

Hello,

I am trying to rename and copy an embedded file to a directory, but each time I try I am left with the old version, not the new one. Can anyone see something I am obviously doing wrong? Can I even do this with embedded files? My goal is to not have loose files next to the app, just the app itself.

#AutoIt3Wrapper_Res_File_Add=File_m.xml

; Find home directory
$Location = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Webber", "Home Directory")

;FileDelete($Location & "\File.xml") - tried this, did not seem to help...

; Copy/move File_m.xml to webber folder
;FileCopy("File_m.xml", $Location & "\File.xml", 1)
FileMove("File_m.xml", $Location & "\File.xml", 1)

Thanks for any suggestions,

-Mike

Link to comment
Share on other sites

Just curious, does $Location contain the proper string you are looking for?

The other code looks right.

To check use:

ConsoleWrite($Location)

in Scite.

Bob

Hi Bob,

I added your check:

#AutoIt3Wrapper_Res_File_Add=File_m.xml
; Find home directory
$Location = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Webber", "Home Directory")
;ConsoleWrite($Location)
MsgBox(0x40, 'Directory', $Location, 5)


;FileDelete($Location & "\File.xml") - tried this, did not seem to help...

; Copy/move File_m.xml to webber folder
;FileCopy("File_m.xml", $Location & "\File.xml", 1)
FileMove("File_m.xml", $Location & "\File.xml", 1)

but wasn't sure what I should see, so I changed it a bit. The feedback I received was correct. In fact, when I add the file delete line, I see the file go away, then appear. So I believe I'm in the right location. But when I check the xml file...it has old code. :-(

Will both FileMove and FileCopy allow renaming along the way?

Thanks for looking at this.

-Mike

Edited by mdwerne
Link to comment
Share on other sites

Ok...so I think I just learned something.

I was trying to embed the xml file into my compiled .exe, that way I would not have to send the xml file to the customer, just the compiled exe.

I can't do that, can I?

-Mike

Sure you can!

Inlcude data in your script and EXE!

Link to comment
Share on other sites

Is the file "File_m.xml" in the same directory as the script?

You may need the full path of the file to move. Try:

FileMove(@ScriptDir & "\File_m.xml", $Location & "\File.xml", 1)

You can imbed the file into your exe using FileInstall. This has a source directory and a copy directory. Upon compiling it will put the file into the exe. At runtime it performs a "copy" routine to the proper location. But this will then always copy the xml file that is embedded. If you want to only put it there if it doesn't exist you need to check to make sure the file doesn't exist first.

Bob

You can't see a rainbow without first experiencing the rain.

Link to comment
Share on other sites

Is the file "File_m.xml" in the same directory as the script?

You may need the full path of the file to move. Try:

FileMove(@ScriptDir & "\File_m.xml", $Location & "\File.xml", 1)

You can imbed the file into your exe using FileInstall. This has a source directory and a copy directory. Upon compiling it will put the file into the exe. At runtime it performs a "copy" routine to the proper location. But this will then always copy the xml file that is embedded. If you want to only put it there if it doesn't exist you need to check to make sure the file doesn't exist first.

Bob

@Szhlopp - Thanks for the link, I can already see a potential use for your UDF.

@YellowLab - Yep, FileInstall is EXACTLY what I needed! Works perfectly!

Now all I need to do is figure out how to Stop a Service...Copy a File...and...ReStart a Service under Vista, then this project is DONE!!

Thanks to you both and have a great week!

-Mike

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