Notes Client On USB Key – The Starter

As I posted earlier this week, I was about to write a small starter application that would do all the necessary changes to the notes.ini when you have a notes installation on an usb key. Well here it is: nstart.exe
When you plug in your usb key to a different computer, you cannot be sure to have the same drive letter for your usb device than before.
In this case your Notes won’t start and you have to tweak the notes.ini manually.
Copy nstart.exe to the notes root directory. When you double click nstart.exe, the tool will set all occurencies of drives ( for example e:\ ) to your current drives letter and then start notes.exe.
The code is still very beta; it should have more error handling, I know. But I decided to release the code in this very early state. The code works for me but maybe not for you. So please give me a feedback when you find the code useful. Even if you think this stuff is crap, please let me know. And if you find errors ( and I’m sure you will ) just leave a comment.

// nstart.cpp
#include "stdafx.h"
#include "nstart.h"
#include "CPathSplit.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;

#define NOTES_INI "notes.ini"
#define NOTES_PRG "notes.exe"
#define BACKSLASH ":\\"

CWinApp theApp;
CFile* fin = NULL;
CFile* fout = NULL;
CFileException ex;
CString Drives ="CDEFGHIJKLMNOPQRSTUVWXYZcdefghijklmnopqrstuvwxyz";
char AppPath[MAX_PATH];
int i, n, j;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
int nRetCode = 0;

if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
cerr < < _T("Fatal Error: MFC initialization failed") << endl; nRetCode = 1; } else try { GetModuleFileName(AfxGetApp()->m_hInstance,AppPath,MAX_PATH);
CString l_oStrPath = AppPath;
CPathSplit l_oPathSplit(l_oStrPath);

CString l_oStrFileExt;
CString l_oStrPathCustom;
l_oStrFileExt = NOTES_INI;
l_oStrPathCustom = l_oPathSplit.GetPath(ePATHEL_DIRECTORY, & l_oStrFileExt);

CString strPath(AppPath);
CString ThisDrive (strPath.Left(1) + BS);

fin = new CFile( l_oStrPathCustom, CFile::modeRead | CFile::shareDenyNone);
ULONGLONG dwLength = fin->GetLength();
char pbuf[99999] = {dwLength}; // read NOTES.INI
UINT nBytesRead = fin->Read( pbuf,dwLength );

CString buffer(pbuf);

// replace drive letters with current drive
for (i=0; i < Drives.GetLength() ; i++) { CString DriveLetter (_T(Drives.GetAt(i) + BS)); j = buffer.Replace(_T(DriveLetter), _T(ThisDrive)); } // write notes.ini fout = new CFile( l_oStrPathCustom ,CFile::modeWrite | CFile::shareDenyWrite); fout->Write(_T(buffer),dwLength);

// start the client
l_oStrFileExt = NOTES_PRG;
l_oStrPathCustom = l_oPathSplit.GetPath(ePATHEL_DIRECTORY, & l_oStrFileExt);
ShellExecute(0, "open", l_oStrPathCustom, 0, 0, 1);

catch (CFileException* pEx)
// if an error occurs, just make a message box
nRetCode = 1;
catch (...)
nRetCode = 1;

return nRetCode;

Download Source

15 thoughts on “Notes Client On USB Key – The Starter

  1. Doesn’t Notes installation write some *necessary* DLL files to Windows directory and keys to Windows registry?
    What about a Domino server on USB? 🙂

  2. When running this app, the notes.ini file get over written with a blank notes.ini file (0Kb in size). Any suggestions?

  3. Ja, this happens when the replace_string function runs into an error.
    I suggest that you configure the usb key installation once manually. When you then run the nstart.exe, the error should not occure.
    As I said, the tool is very, very beta and needs some error handling. 🙄

  4. The process actually worked twice and then would no longer function as it should. We’ve tried it on 10 different PC’s. Is there anything I could go to help with this problem?? 💡 Did you use Perl to write this?

    Hopefully we can determine the cause of this problem whether locally on my end or within the code. When it worked previously it was great 😆

  5. #4
    >> Did you use Perl to write this?

    No, the code is written in C / C++

    >> Hopefully we can determine the cause of this problem whether locally on my end or within the code

    I could reproduce the error. And I could determine what causes this issue.

    Open your notes.ini and scroll down to the end of the file. There should be one CRLF.
    Then use nstart to start the client.
    Close the client and re-open notes.ini.
    Now you should have end extra CRLF, right ?
    Start the client for a second time using nstart.
    When you now look into notes.ini, there is another CRLF at the end.
    If you try to start the client for the third time … kaboom ! 😈

    With a fresh copy of your notes.ini, start the client again and after closing, delete the additional CRLF. Do this after every client shutdown and you can start the client with nstart as often as you like.

    I will fix this as soon as I’m back in my “lab”

  6. #5

    >>Open your notes.ini and scroll down to the end of the file. There should be one CRLF.

    Correct. After the last line of text there is a CRLF 🙂

    >> Then use nstart to start the client.
    >>Close the client and re-open notes.ini.
    >> Now you should have end extra CRLF, right ?

    No…Now the notes.ini file is completely blank. 🙁

    I also tried it on a clean install of Lotus Notes prior to setting up a user so the Notes.ini file only stated:

    Directory=Q:\Program Files\lotus\notes\data

    (Q:\ is my thumb drive)

  7. I downloaded your new nstart.exe and tried it once again. The same problem is occuring. The notes.ini file is being replaced with a blank notes.ini file. Tried it on a different machine and thumb drive.

  8. #8

    I did the following

    – start the client via nstart
    – close the client
    – wait 10 sec or so

    everything is OK

    – start the client
    – close the client and restart immediately …

    KABOOM !!!

Comments are closed.