How Do I make Arduino stop opening the last opened file?

I have to send a screen capture to a company to get support, I have to move some folders around and then open the Arduino IDE on camera, thing is, I don't want them to see the last sketch (or any sketch for that matter) and Arduino always opens the last one, even when opening the Arduino zip with the sketchbook on a random folder, opens the last arduino sketch opened with the installed version. EVEN if I go to C:\Users\<user>\.arduinoIDE\recent-sketches.json and C:\Users\<user>\.arduinoIDE\recentworkspace.json delete everything in there and SOMEHOW manages to find again the last opened file, open it again and putting the information back into those files.

Like idk Arduino, maybe TAKE THE HINT, if I'm manually deleting data inside hidden configuration files, MAYBE I don't want you to open anything in those files!

Sorry for the rant, can you guys please help? this is driving me insane.

When it starts IDE 2.x opens the last sketch that was saved so all you have to do is to save a simple sketch, or an empty one for that matter, before opening it again

Hi @MrWilliam932.

It is pointless to obsess over this. You are making a throwaway screencap that a random support technician is going to look at once, not a piece of fine cinema.

The Arduino IDE application has a sketch-per-window design. So you must have a sketch open to have the IDE open.

You would need to also delete this file:

C:\Users\<user>\AppData\Roaming\arduino-ide\config.json

Or if you want to be more surgical, instead of deleting the file open it in a text editor and remove the content of the workspaces array.

However, there isn't a point in doing that in this case because Arduino IDE will fallback to creating a new sketch if there isn't a previous sketch to restore. So it is more simple to use the approach provided by @UKHeliBob.


On the off chance you happen to be interested in the boring details of how the sketch restore system works, I'll mention there is a detailed explanation here.

It's not something I'd be driven insane, anyway before starting the screen recording, you might just create a "fake" Arduino using a batch file and an "empty" *.ino. It's something you can do just once.
Let's say your IDE is located at "c:\Users\<user>\AppData\Local\Programs\Arduino IDE\Arduino IDE.exe" where "" is your current Windows user.

  1. Create an "empty.ino" file with the standard "new" ino, let's say it's "c:\Users\<user>\Documents\Arduino\empty\empty.ino"
  2. Create an "arduino.bat" somewhere (e.g. your Documents folder) with this content (a single line!):
"c:\Users\<user>\AppData\Local\Programs\Arduino IDE\Arduino IDE.exe" "c:\Users\<user>\Documents\Arduino\empty\empty.ino"
  1. Create a shortcut to that .bat file on your Desktop, rename it just "Arduino".
  2. Edit the shortcut properties to change the icon (pick the "Arduino IDE.exe" file one) and set it to start as an icon.

This is the result:

Now if you start the recording and double click that shortcut, the IDE will start with that "empty" code, and no one can tell if you did this trick or not.
Hope it helps.

Why the need for a reick trick of any sort ?

EDIT : corrected mistyped word

There is no need, it's just a way to satisfy that "requirement" :smiling_face_with_halo:

Surely it is much easier just to use the IDE rather than messing around with a shortcut to a batch file

Agree, and that's what I'd do. But if the OP just wants to mock it while recording, it's the way I thought about. Not a "final solution" but for what it's worth... :wink:

In this specific use case of only wanting to start Arduino IDE with a minimal or empty sketch one time, I think @UKHeliBob's approach is best due to being the most simple.

However, we have received reports that some users would like to permanently disable the sketch restore feature. For that use case, @docdoc is definitely a good one.

However, I would simplify it by just configuring the shortcut to pass the argument to the "empty" sketch instead of using a batch file for that purpose:

  1. Right-click on the Windows file shortcut for Arduino IDE.
    A context menu will open.
  2. Select "Properties" from the menu.
    The properties dialog will open.
  3. Add the "empty" sketch path argument to the "Target" field in the dialog.
    For example, if the content of your "Target" field is originally this:
    "C:\Users\<user>\AppData\Local\Programs\Arduino IDE"
    
    And the "empty" sketch is at this path:
    "C:\Users\<user>\Documents\Arduino\empty\empty.ino"
    
    Then you would change the content of the "Target" field to this:
    "C:\Users\<user>\AppData\Local\Programs\Arduino IDE" "C:\Users\<user>\Documents\Arduino\empty\empty.ino"
    
  4. Click the "OK" button in the properties dialog.

As with @docdoc's approach, when you start Arduino IDE via that file shortcut, it will open the sketch at the path you specified via the argument in the "Target" field instead of restoring the previous sketch.

The old version opened a new sketch each time with a temp name like "sketch_xxxxxx", when you hit save, it prompts you to save the file with a name you choose. The new feature is great and all but I think other than OP's specific case would be a nice option. And personally I don't think adding a checkbox that selects if you want to open a new file or the last one by default would take a developer more than 10-15 minutes to implement.

This is incorrect. Arduino IDE 1.x has the same sketch restoration behavior as Arduino IDE 2.x.

Both versions fall back to opening a new sketch if you didn't have a saved sketch open during the previous session, or if the sketch you had open is no longer accessible (e.g., you deleted the sketch between sessions).

The Arduino IDE developers are tracking the request for the addition of a setting to disable the sketch restore behavior here:

If you have a GitHub account, you can subscribe to that thread to get notifications of any new developments related to this subject:

Ah yes, you are right I remember now editing files to disable that behavior, but at least IT WAS POSSIBLE. Now it doesn't. Also the Github Issue doesn't have any updates since 2023 so... not expecting anything any time soon

It is still possible. @docdoc described it in post #4 and I provided detailed and refined instructions for that approach in post #9.