Sumatra PDF is a PDF, ePub, MOBI, CHM, XPS, DjVu, CBZ, CBR reader for Windows

How to automate opening a PDF from an external drive when the drive letter varies?

SumatraPDF-3.2-32 is installed on a USB stick and works fine, I can open a PDF document in landscape, one full page at the time.
But… The drive letter of the inserted stick varies due to use on different computers (used on universities on a video wall/screen for educational purpose)
So the file sumatrapdfcache is often pointing to the wrong drive letter.
I think I did read evertything about additional command-line options and changing the *.ini (settings) file.

I want to start SumatraPDF-3.2-32, and open automaticly at start up a file named “lecture-sept.pdf”. Manually selecting next page.
The drive letter -as mentioned- varies. Sumatra, settings file, sumatrapdfcache, and the PDF are in te same map on the stick.
-presentation : display in presentation view?
-fullscreen : display in full screen view?
-view “single page” or “continuous single page” (one full page at the time)?

I can write batch (cmd) files, no problem.
Can some pls help me out with the necessary settings? Thanks beforehand.

\sumatrapdfcache should not be an issue itself as it should be “relative” in the same folder as the portable.exe (avoid any “portable app” variations that may fiddle with the data files, some are good but some are not)

So there should be no problem dropping a usb.pdf onto the usb sumatrapdf.exe with -fullscreen and the solution below is only needed for multiple tab users.

For one file all you need is a bat file with

"%~d0\Apps folder\SumatraPDF\SumatraPDF.exe" -fullscreen "%1"

that alows you to drop a file onto it
or to simply double click the bat file change that to

    "%~d0\Apps folder\SumatraPDF\SumatraPDF.exe" -fullscreen "%~d0\Data files\lecture-sept.pdf"

The main problem could be in the history of more than one file that you opened last time on the F drive but now are in the same folder on G

The simplest solution in that case is to replace in SumatraPDF-settings.txt any previous F:\ with G:\

There may be clever ways to do that in raw powershell vba wscript etc.HOWEVER as there is a risk you may not find that on ALL other machines or be restricted then I suggest its simplest to use just .batch .cmds

  • combine storing the current drive letter (for next time) which is as simple as echo %~d0

  • combine with a simple find and replace tool (my favorite would be FART https://github.com/lionello/fart-it) and replace with the current FileDrive so

FilePath = %~d0[etcetera]

If the drive is the same as %lasttime% it wont matter so adding that all up in your cmd

call %~d0\lastdrive.bat
"%~d0\Apps\File Tools\fart\fart199c\fart32.exe" -i "%~d0\Apps\SumatraPDF\SumatraPDF-settings.txt" "FilePath = %lastdrive%" "FilePath = %~d0"
echo set lastdrive=%~d0> %~d0\lastdrive.bat
"%~d0\Apps\SumatraPDF\SumatraPDF.exe" -fullscreen "%1"
pause

and that last %1 allows you to drag a different first file (lecture-sept.pdf if you wish) onto the cmd to start the session off or replace the "%1" with

"%~d0\Apps\lecture-sept.pdf"

of course you can remove \ edit those folders and subfolders as you wish

Thanks! It works fine.