Can both Arduino and Processing code be saved on the same board

I'm working on a project that involves having to use Arduino and Processing. I'm using Processing along with Arduino to create a GUI. I want it to work so that both the codes can be saved onto the board. When the Arduino board is connected to the PC, it will either automatically open up the GUI or click the executable file that's in the Arduino board to open up the GUI if that's even possible.

Is anything I mentioned doable?

No. Processing applications run on a PC, not on your board.

With certain boards you can send commands to a PC; that way you can start an application. These are the boards with native USB (that you can use as a HID). 32U4 based boards like Leonardo, Micro and ProMicro and a whole range of the newer Arduinos that I'm not familiar with.

I'm not sure why you decided to use Processing; if it is for cross-platform compatibility (run on Windows, Linux and Mac) it might be a bit tricky to implement a one-is-all for the different operating systems.

The only way I can think of is to have them both independent but part of the same sketch. In you setup you will have to determine where you want to go and set the hardware up correctly. Then in loop you need to select one of two pieces of code. Eich piece of code could be a function that does not exit. You will always skip the section you do not want. It is convoluted but it will work.

If you could install and run a custom code on any PC by just plugging in an arduino to your USB port, don’t you think you would have a major security issue (like the infamous autoexec.bat in the old DOS days)...

Or autorun.inf with a flash drive and CD/DVD on Windows system.

.inf like infamous :wink:

Yes. Well said.