lonardd Posted February 27, 2019 Share Posted February 27, 2019 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 More sharing options...
BrewManNH Posted February 27, 2019 Share Posted February 27, 2019 (edited) 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 February 27, 2019 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 GudeHow 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 More sharing options...
Bowmore Posted February 27, 2019 Share Posted February 27, 2019 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 More sharing options...
TheXman Posted February 27, 2019 Share Posted February 27, 2019 @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. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
lonardd Posted March 8, 2019 Author Share Posted March 8, 2019 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 More sharing options...
BrewManNH Posted March 8, 2019 Share Posted March 8, 2019 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 GudeHow 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 More sharing options...
Bowmore Posted March 9, 2019 Share Posted March 9, 2019 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 You are mistyping the command-line parameter "/ExtractSourceCode" 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now