Portable Mode in paint.net 4.0.17+

In the announcement post for 4.0.17, I mentioned that there was a new “portable mode” and to “see blog/forum post for details.”

What does it do

1) This will move Paint.NET’s internal AppSettings (not to be confused with .NET’s idea of “appSettings”) to be stored in a JSON file called PaintDotNet.AppSettings.json. Since it’s JSON you can use any JSON tools to read, write, or process it. The location of this file is not currently configurable; it will always be in the same directory as PaintDotNet.exe.

Paint.NET’s internal AppSettings covesr things like the window positions and sizes, and any changes you make in Settings (e.g. Tool defaults), as well as the settings you use for saving files (e.g. JPEG quality).

2) The updater will not be enabled in this mode, and the UI for it will not be available in the Settings dialog.

3) At startup, Paint.NET checks to see if there are any missing files from the installation. If anything’s missing, it offers to run a repair. Since repair is done by reinstalling the MSI, and this isn’t possible in portable mode, this behavior is also disabled.

4) Effect plugins can actually query the install type/state via the IAppInfoService and the InstallType property. Use the GetService() method to do this. I’m not sure if this will be useful Smile

How to enable it

You’ll have to modify the file PaintDotNet.exe.config. In general, I don’t recommend doing this, as there are some weird and scary settings in there which have been collected and fine-tuned over the years to craft just the right behavior for Paint.NET’s use of the .NET Runtime. But, this file is also capable of holding application-specific settings for some bizarre reason.

You’ll want to add a new setting called PaintDotNet.EnablePortableMode with a value of true in the <appSettings> section, toward the bottom of the file:

<?xml version="1.0"?>
<configuration>
  <runtime>
    <gcAllowVeryLargeObjects enabled="true"/>
    <generatePublisherEvidence enabled="false"/>
    <legacyCorruptedStateExceptionsPolicy enabled="true"/>
    <loadFromRemoteSources enabled="true"/>
  </runtime>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
  </startup>
  <appSettings>
    <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
    <add key="PaintDotNet.EnablePortableMode" value="true" />
  </appSettings>
</configuration>

How to get a “portable” copy of Paint.NET

With this addition, you should no longer need to go to a 3rd-party site to get a “portable” version of Paint.NET, although maybe they’ll still offer some added value that I’m not aware of, like also including a “portable” copy of the .NET Framework 4.6.

All you need to do is:

  1. Install Paint.NET on any system
  2. Copy the installation folder, which is usually C:\Program Files\paint.net, to a USB stick (or wherever)
  3. Enable “portable mode” as described above, by editing the .exe.config file
  4. Take the USB stick to any other PC that already has .NET Framework 4.6 installed, and then run PaintDotNet.exe
  5. Voilà! Now you have a portable copy of Paint.NET.

Conclusion

And there you go Smile Paint.NET has already been capable of running “portable” with respect to its installation dependencies, other than .NET itself, due to changes in the Visual C++ runtime and Universal C Runtime deployment peculiarities. The ability to route the app settings to a local file, however, is a new addition, and will ensure that Paint.NET doesn’t feel like it’s been “reset” every time you run it on a new computer.

Advertisement

17 thoughts on “Portable Mode in paint.net 4.0.17+

  1. Matt says:

    Thanks very much, being running ‘portable’ for a while, and this is a very welcome addition!

  2. Alex says:

    Is there a performance penalty when running portable? Don’t you run ngen after installation?

  3. pbr says:

    After implementing portable mode, paint.net still leaves a folder called “paint.net” at C:\Users\~\AppData\Local\ which contains two more folders, “Optimization” and “SessionData”. “Optimization” contains one file, “Startup.0.profile,” and “SessionData” contains another (empty) folder with a name consisting of digits which change each time you open and close the program. (It also creates the “PaintDotNet.AppSettings.json” file where it’s supposed to.) I am running the application from a folder on my hard drive, not from a flash drive. Is that the problem? Win7 Pro SP1.

    • Rick Brewster says:

      Someone else asked this on the forum and I replied to it: https://forums.getpaint.net/index.php?/topic/111572-paintnet-4017-is-now-available/&do=findComment&comment=533378

      Put simply, I don’t think you would want the data stored in these folders to be stored next to the application, especially if you’re running from an actual USB stick. Paint.NET’s “portable” mode isn’t meant to be a “stealth” mode. (Although in the next update I do need to make sure that “Paint.NET User Files” is stored locally and not in MyDocuments.)

      The “Optimization” folder is used to power .NET’s Multicore JIT feature. These files are small and may be system-specific.

      The “SessionData” folder is for scratch data. History undo/redo stuff. Putting this on the USB key would be really slow and not a good idea.

      • Jason Martins says:

        Would it be possible to at least make “stealth” mode an option? I’m running Paint.NET from a *fast* portable SSD and wouldn’t mind the additional writes as long as the app is truly 100% portable.

        • Rick Brewster says:

          Can you give me more information? I don’t understand why you would need it to be “truly 100% portable” because it’s just not something that is a goal for my own PC usage. If you could explain it to me, that would help me out and also help to steer the implementation in the right direction.

          • fuflo says:

            From the years observing “portable” users ideology, they seem to not touch the host OS and/or files at all when in portable mode.
            I myself only use portable applications to ease the maitenance of a pc – reinstalling/backup etc.

            Also, while i appreaciate the effort to make paint net portable, i have a question: how do i update the portable installation? do still have to install a fresh version on some pc and grab the extracted files, overwrite to my portable instance? Most other applications provide a simple zipped version of the files for portable use, but i don’t see paint.net having that anywhere. Of course i could extract exe/msi with some tools, but just wondering if there’s a simplier method.

            • Rick Brewster says:

              Currently, Paint.NET’s portable mode is very much in “DIY” territory. I’m hoping to improve it as time goes on. So yes, currently you’ll have to check for updates yourself and then download the installer, install it somewhere, and then copy the installation folder. There’s nothing preventing me from providing a separate portable ZIP on the downloads page, I’ve just been prioritizing other work (e.g. Windows Store stuff).

              • Jason Martins says:

                Paint.NET definitely needs a portable *Out of the Box* ZIP distribution now to go with the normal installer. Having to install and copy the files every time to update it isn’t a great way to do things.

          • Jason Martins says:

            There may be times when we need to run portable apps on systems where we don’t have admin access. I also love the fact that I have a suite of “true” portable (i.e. “stealth mode” capable) apps on an external HDD /SSD that I can call upon on any system (at a cyber cafe, friend’s place, customer etc.) and do my work while leaving little to no traces behind (well, other than Windows’ own minor MRU/ShellBags stuff etc.)

            So if you can see a way to make Paint.NET truly stealth mode capable, that would be simply an awesome icing on the cake IMO. Thanks! 🙂

            P.S. Same guy as above; sorry took so long to reply.

  4. Miki says:

    I tried to do this on my computer so that I can use Paint.Net on my work laptop (I can’t install it there because of admin issues). However, When I try to run it from the USB flash drive I moved it to, it gives me a “Windows cannot access the specified device, path, or file” error. Is this still an admin issue, an issue with my USB, or something else entirely?

  5. Ian Yates (@IanYates82) says:

    Regarding the need to edit the .config file directly, you could include a simple config file alongside the main .config file – your code doesn’t have to change at all to support it.

    Your .config file changes from

    ..whatever you have in here..

    to

    ..whatever you have in here..

    That custom.config file then could just be

    and users can modify it to suit.

    The .NET runtime will seamlessly blend (via overwrite) the settings from custom.config with those from your regular app.config

    It might make some of these changes a little less scary and less likely for people to muck things up (and eventually submit to the forum, costing you time/effort)

    I Googled around to find a reference – this is the first I could find… http://www.c-sharpcorner.com/blogs/add-reference-external-config-files-in-webconfig1

    I found plenty of links saying you could use a configsource attribute instead – I’ve not had experience with it.

    Anyway, thought it might be handy and, for a bonus, doesn’t require you to change code 🙂

  6. Royi Avital says:

    Great!

    Rick, answering your questions:

    I like using portable applications all across my applications (Usually using PortableApps when it is offered) in my main computer, not even in a USB but just on a secondary HD.
    When I say portable I mean 3 things:
    1. Doesn’t leave any trace on the computer (Registry, files, settings, etc…).
    2. All settings are located in the program folder.
    3. Doesn’t require any privileges (Administrator, etc…).

    The reasons are simple:

    1. It mitigate the tendency of Windows to get slower with time as the registry and all other things revealed to the OS are the same as they are in the first day of installation. Besides updates the OS is clean.
    2. Applications are disconnected form OS. It means I can format my computer any time and once the installation of Windows is done (Very quickly these days) I have a fully working computer.
    3. Security – No installers which are granted Administrator rights. Besides updates of Windows nothing ever gets Administrator rights.

    Actually, I think this model should have been the design choice of Windows.

    Regarding Pain.Net:

    1. I wish portable mode was part of the installer (Which shouldn’t be granted Administrator Rights unless the destination directory requires so).
    2. Better choice would be utilizing PortableApps framework.
    3. Please make it real portable. Nothing to be left behind, no registry, no files, nothing. If the program needs temporary files, great, use them. But just like walking in New Zealand, leave nothing behind.

    Thank You.

Comments are closed.