Jump to content

FileInstall Strange behaviour


lonardd
 Share

Recommended Posts

Hi,

I have a source Script where I inserted the following code lines to be able to extract the script source code anytime later if I run it with the /ExtractSourceCode:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Res_SaveSource=Y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
If StringInStr($cmdlineRaw, "/ExtractSourceCode") Then
    FileInstall(@ScriptFullPath, @ScriptDir & "\" & @ScriptName & ".txt", 1)  
    ;FileInstall("C:\Test.txt", @ScriptDir & "\Test.txt")
    Exit
EndIf

I used to be able to compile it on another computer some years ago without problems.

Now I wanted to modify the code, so I extracted it, renamed the file *.au3, performd my little modification and rebuild.

Strangely, I get this popup with Caption: Aut2Exe Error and Invalid FileInstall() function.

BEfore I hit the OK button on the Popup, I can see the file is actually Built as I can see that an EXE file is created, but as I hit OK in that error dialog, the EXE disappears.

Any advice?

Thanks

David

I can't remember if I did it with Autoit 2 

EPP_NF_Replacer_UBI.au3

Link to comment
Share on other sites

I can't replicate this, I get the EXE file and it extracts it ok when the executable is ran.

Can you copy and paste the output panel from SciTE when you compile it and get the error message to see the full output messages?

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This line is invalid. You can't use macros or variables as the source value  in FileInstall. You must use literal paths and file names.

FileInstall(@ScriptFullPath, @ScriptDir & "\" & @ScriptName & ".txt", 1)

It needs to be something like this

FileInstall("C:\dir1\dir2\myscript.au3", @ScriptDir & "\" & @ScriptName & ".txt", 1)

Or

FileInstall(".\myscript.au3", @ScriptDir & "\" & @ScriptName & ".txt", 1)

 

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

@Bowmore

40 minutes ago, Bowmore said:

You can't use macros or variables as the source value  in FileInstall. You must use literal paths and file names.

Actually there is an exception.  From the help file:

Quote

The only exception to the above, is that the source file may be @ScriptFullPath - this allows you to include the source script.

 

Link to comment
Share on other sites

  • 2 weeks later...
On 2/27/2019 at 9:58 PM, Bowmore said:

This line is invalid. You can't use macros or variables as the source value  in FileInstall. You must use literal paths and file names.

FileInstall(@ScriptFullPath, @ScriptDir & "\" & @ScriptName & ".txt", 1)

It needs to be something like this

FileInstall("C:\dir1\dir2\myscript.au3", @ScriptDir & "\" & @ScriptName & ".txt", 1)

Or

FileInstall(".\myscript.au3", @ScriptDir & "\" & @ScriptName & ".txt", 1)

 

As per your suggestion I tried this:

    FileInstall(".\EPP_NF_Replacer_UBI.au3", @ScriptDir & "\" & @ScriptName & ".txt", 1) and it now compiles. The problem is that it does not do what I want that is extracting the source code into a TXT file.

 

Link to comment
Share on other sites

3 hours ago, lonardd said:

The problem is that it does not do what I want that is extracting the source code into a TXT file.

So, what does it do instead?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I downloaded your script in your first post and compiled it unaltered then executed it from a command prompt as
Monitors>P:\Downloads\EPP_NF_Replacer_UBI.exe /ExtractSourceCode

This created a file 

P:\Downloads\EPP_NF_Replacer_UBI.exe.txt 

Which contains the the original source code from P:\Downloads\EPP_NF_Replacer_UBI.au3

From this I can see only 2 possibilities why this is not working for you

  1. You are mistyping the command-line parameter "/ExtractSourceCode"
  2. Your anti-virus is seeing this as suspicious behaviour and deleting the extracted file.

 

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

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

×
×
  • Create New...