willichan Posted July 26, 2010 Share Posted July 26, 2010 I already have a strong suspicion that the answer to this is, "No. It can't be done." but I'll ask anyway. Is there any way for a script to detect whether it is running as the main script, or if it is being included in another script? My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
electrico Posted July 26, 2010 Share Posted July 26, 2010 I have no certain answer, but I think that there is a way to determine if the exe file was extracted (being as a child from other process) or it is the only process. May be this could be done analyzing process table before process and after it. This is my opinion. Link to comment Share on other sites More sharing options...
willichan Posted July 26, 2010 Author Share Posted July 26, 2010 @electrico Thank you for your reply. I probably wasn't very clear on what I was looking for. I am looking to have the script (compiled or not) determine if it is being run as a script, or being included as a UDF. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 26, 2010 Share Posted July 26, 2010 Not possible. The reason is that if you are using #include, it should be a file that is always meant to be #include-d. Link to comment Share on other sites More sharing options...
willichan Posted July 26, 2010 Author Share Posted July 26, 2010 Not possible. The reason is that if you are using #include, it should be a file that is always meant to be #include-d.That is what I suspected. Thank you. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
_Ed_ Posted March 11, 2023 Share Posted March 11, 2023 (edited) ? If @ScriptName == "xyz.au3" Then ; running as "main" script Else ; running as #included EndIf Edited March 11, 2023 by _Ed_ Link to comment Share on other sites More sharing options...
Developers Jos Posted March 11, 2023 Developers Share Posted March 11, 2023 @_Ed_, You do realize you are answering an 12+ years old thread? Please don't and stick to recent topics! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts