Yes, this is possible and is pretty straight forward as well. Firstly, you need to add the following to your modules XML file:
<scriptfile>script.php</scriptfile>
And of course, going by this, you will need to create a file called script.php or whatever you wish to call it. Just make sure you change the file name in the code above accordingly. Them, in the file, add the following code:
<?php
defined('_JEXEC') or die('Restricted access');
class com_helloWorldInstallerScript
{
function postflight($type, $parent)
{
// all your code goes in here
}
}
Simply add your code in the postflight function which will then get executed after the module has been installed. Joomla also provides 4 other built in functions:
- install
- uninstall
- preflight
- update
These may also come in handy for the future. more information can be found on all of this here:
https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_an_install-uninstall-update_script_file
Hope this helps