Reply to topic

Problems Making Windows KMyMoney Version Portable

Stephen Leibowitz
Registered Member
I am trying to make KMyMoney portable, in the sense that it could run from a thumb drive. I have done this for other programs, such as digiKam and Krita, and published it. But I am experiencing problems with KMyMoney.

The first time I run KMyMoney 5.0.6 (64-bit) on my Win 7 system, it installs two folders at the beginning of the New File Setup:

Later the program installs another folder:

(“USER1” is for consistency with the rest of the post.)

These storage locations on Win 7 are a problem. I would like to use environment variables to store and access the aqbanking, .config, and .cache folders on the same thumb drive to which I copy the decompressed .7z program files. I could do this easily if the path to these three folders is in AppData, such as {username}\AppData\{Roaming or Local}. That seems to be the case on Win 10:
The easiest way is insert all codes in file "kmymoneyrc".
Windows 10 path: "c:\Users\USER1\AppData\Roaming\.kde4\share\config\kmymoneyrc"

I ran the program from a thumb drive after setting the environment variables %USERPROFILE% and %HOMEPATH%:
set USERPROFILE=\kmymoney5-5.0.6
set HOMEPATH =\kmymoney5-5.0.6

but the program continued to store the folders on the hard drive in C:\Users\USER1. I also tried the environment variables KDEDIRS and KDEHOME, but with no effect.

Also, three processes remain active when the program ends. The system will not say that it is safe to eject the thumb drive with them active. I can start Task Manager and manually end the processes. I can also use the Windows TaskKill command. Perhaps the KMyMoney developers would consider ending the processes on the Windows version when the program exits:
User avatar ipwizard
KDE Developer
I am pretty sure that you are not able to achieve what you want without compiling the source code and tweak it to support your portable environment. This includes AqBanking (which has a --enable-local-install configure option that might help) and may also be true for other libraries (KDE Frameworks as well). I am no Windows expert so I can't give you an advice here.

ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.1 64bit, KF5
Registered Member
Is it worth the effort as Win 7 is no longer supported by Microsoft anyway. Surely it’s time to move to Win 10 first?
Stephen Leibowitz
Registered Member
My goal is to make the Windows version of KMyMoney portable, in the sense that it can run from a removable drive, such as a thumb drive. Windows allows folder redirection for “special folders,” which can be implemented with Windows environment variables. If an application stores significant data in the Windows registry, that would present an obstacle to portability. Fortunately, many applications developed for Linux and ported to Windows, including KMyMoney, do not have that problem.


I installed KMyMoney from the .7z archive onto a system that had no trace of the program. It was version 5.0.6 because that is the most recent binary in the stable branch. I ran the program, and it wrote warning messages to the console:


C:\kmymoney5-5.0.6>3:2020/05/19 10-23-44:gwen(1760):i18n.c: 120: No translation found for WIN32 locale [English_United States.1252]

3:2020/05/19 10-23-44:gwen(1760):plugin.c: 379: Plugin "aqofxconnect" not found.
4:2020/05/19 10-23-44:aqbanking(1760):banking_init.c: 507: Could not load backend "aqofxconnect", ignoring
Note from Stephen: kmymoney5-5.0.6\lib\aqbanking\plugins\35\providers\aqofxconnect.xml is the only aqofxconnect file in the .7z binary download.

path of the process "dbus-daemon" seems to be outside of the installPath: "C:/km
ymoney5-5.0.6/bin" "/usr/x86_64-w64-mingw32/sys-root/mingw"
Note from Stephen: dbus-daemon.exe is in kmymoney5-5.0.6\bin.


The program then guided me through the New File Setup (first run dialog). Here is the file structure it created.

Code: Select all
│       ksycoca5_en_4yxR72+7kky0gLWmsU1OkiLrNkY=
│   └───kmymoney
│       │   checkprintingrc
│       │   kmymoneyrc
│       │   
│       └───html
│               kmymoney.css
│               welcome.css
│   └───settings
│       ├───apps
│       │       kmymoney.conf
│       │       
│       ├───aqbanking
│       │       config.conf
│       │       
│       ├───backends
│       │       aqhbci.conf
│       │       aqpaypal.conf
│       │       none.conf
│       │       
│       └───shared
│               qt5%2dgui%5fab%5fsetup.conf
│   └───Roaming
│       └───gnupg

KMyMoney uses the Qt class QStandardPaths for some of its files. The class takes into account the conventions for different operating systems, as shown by the documentation for the enum QStandardPaths::StandardLocation. On Windows it uses the AppData application data folder where appropriate. But many of the locations used by KMyMoney are determined by KDE software, which is Linux-oriented. That makes portability more complicated.


The following batch file is my solution to making KMyMoney on Windows portable. It uses Windows and KDE/XDG environment variables.

Code: Select all
cd  /d  %~d0\kmymoney5-5.0.6
:: This will set the variables to the KMyMoney program folder.
:: The program uses this as the parent for the application data folders.
:: An alternative is to set the variables to a folder on the same drive,
:: but outside of the KMyMoney program folder.
REM Assigning different paths to the environment variables shows what works.
set        TMP=%CD%\AppData\Local\kmymoney
set KDETMP=%CD%\tmp
set KDESYCOCA           =%CD%\.cache-ksycoca
set XDG_CACHE_HOME=%CD%\.cache
set XDG_CONFIG_HOME=%CD%\.config
set XDG_DATA_HOME=%CD%\.local-share
start "KMyMoney" /Wait bin\kmymoney.exe
taskkill /im dbus-daemon.exe /f /t

To increase the separation from the code, the user can change the batch file to specify a location for the folders that is outside the KMyMoney program folder. After the program ends, the batch file calls the Windows TaskKill command to end D-Bus. I invite users to try it out. You should not use it on an existing installation of KMyMoney. Instead, download the .7z archive of KMyMoney and extract it to a thumb drive or other removable storage. The batch file should be copied to the same drive as KMyMoney, but does not have to be in the same folder.


The user can specify a Log Path in KMyMoney:
Configure > KMyMoney > General > Support

The program stores the path in .config\kmymoney\kmymoneyrc :
[List Options]

Similarly, kmymoneyrc stores the location of financial data files, which usually have a .kmy extension. It also stores the LastUsedDirectory:
LastUsedFile        =driveLetter:/kmymoney5-5.0.6/fileName.kmy

Drive letter assignments can change for removable drives. To point to the removable drive, there should be no explicit drive assignment. The user can manually edit the file to delete driveLetter: .

An alternative is to store .kmy files or log files on a network drive. The Windows Map Network Drive facility or the Net Use command can be used to assign an available drive letter to a network storage space. KMyMoney can then be configured with that drive letter and a folder.

KMyMoney has a backup facility. Using a different drive for backup is often desirable:
File > Backup

I have suggestions for programming changes, which I discuss in the following sections.


This section is in kmymoney-5.0.8\CMakeLists.txt:

# use DBus only on Linux
set(KMM_DBUS 1)

Yet the dbus-daemon.exe always starts with KMyMoney and I have to end it outside of the program. If it is truly not needed on Windows, then perhaps the program can be changed to not start it. Perhaps by making the define for KMM_DBUS in kmymoney-5.0.8\config-kmymoney.h.cmake conditional?


In csvimportercore.cpp there is the following method:

KSharedConfigPtr CSVImporterCore::configFile()
return KSharedConfig::openConfig(QStringLiteral("kmymoney/csvimporterrc"));

I suggest changing the return line to:
return KsharedConfig::openConfig(QStringLiteral("kmymoney/csvimporterrc"),,QStandardPaths::AppConfigLocation);

The method defaultIdSource in ofximporter.cpp could be changed in a similar manner from:
KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("kmymoney/ofximporterrc"));
KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("kmymoney/ofximporterrc"),,QStandardPaths::AppConfigLocation);


In csvimportercore.cpp (CSVProfile::writeSettings), there is the statement:

if (m_lastUsedDirectory.startsWith(QDir::homePath())) // replace /home/user with ~/ for brevity
m_lastUsedDirectory.replace(0, QDir::homePath().length(), QLatin1Char('~'));

That may be fine for Linux, but not Windows. I suggest that the code be made conditional:

#ifndef Q_OS_WIN
if (expression)      // replace /home/user with ~/ for brevity


In kmymoney.cpp and kaccounttemplateselector.cpp, the URL in a comment should be changed from:


KMyMoney has an encryption facility. The New File Setup created an empty folder gnupg. The documentation in section 22.3.2 says, “On the encryption page of the settings dialog, there is a drop down list where you can select the key that should be used for encryption and decryption.” I have GNU Privacy Guard version 2.2.20 installed. But I did not see any reference to encryption within Settings in the Windows version. Encryption would be useful when running KMyMoney from a portable drive because of the possibility of losing the drive.


I tested KMyMoney’s code with Cppcheck. It flagged many things. Most are of minor importance. But at least some appear to be worth fixing. For instance, it flags a memory leak in two locations. One leak is pGroupMarker in register.cpp:

KMyMoneyRegister::StatementGroupMarker *pGroupMarker = new KMyMoneyRegister::StatementGroupMarker(this, eRegister::CashFlowDirection::Deposit, QDate::fromString(d->m_account.value("lastImportedTransactionDate"), Qt::ISODate), txt);


A delete statement should be added.

Another type of problem is in two locations in mymoneytemplate.cpp. Here is the code:

bool rc = true;
while (rc == true && !account.isNull()) {

Condition 'rc==true' is always true.

Cppcheck allows you to filter the results by message type, such as error, warning, etc. It also allows you to apply a quick (string) filter. Here are sone quick filters that I used:

always true
always false
be const
never used
memory leak
no effect

Cppcheck is free software. It comes in Linux, Windows, and Mac versions. It is not the only checker for C++ worth considering. There are also the clazy and Krazy checkers. But Cppcheck is easier because it comes in a standalone, precompiled form.

Reply to topic


Who is online

Registered users: Baidu [Spider], Bing [Bot], Garthhh, Google [Bot], ostroffjh, Sogou [Bot], Yahoo [Bot]