Windows allows you to set up a debug process when a process exits. This module uploads a payload and declares that it is the debug process to launch when a specified process exits.
Windows
To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':
msf > use exploit/windows/local/persistence_image_exec_options
msf exploit(persistence_image_exec_options) > show targets
...targets...
msf exploit(persistence_image_exec_options) > set TARGET < target-id >
msf exploit(persistence_image_exec_options) > show options
...show and set options...
msf exploit(persistence_image_exec_options) > exploit
Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.
– Jim O’Gorman | President, Offensive Security