Lightroom SDK: LrApplication.getPath() -- get path to Lr executable file

  • 1
  • Idea
  • Updated 4 years ago
It would be helpful, e.g. when creating bat files which start or restart Lightroom, to know path to Lightroom. Tnks, R.

It's easy enough to have field for user to edit, but then it needs to be fixed everytime user updates Lr version.
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 372 Reply Likes

Posted 4 years ago

  • 1
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 372 Reply Likes
Workaround, which relies on fact that Lr's factory default develop presets are in with application program files:

function Lightroom:computeLrAppPathUsingDevelopPresetFolders()
local presetFolders = LrApplication.developPresetFolders()
for i, v in ipairs( presetFolders ) do
if v:getPath():find( "Adobe Photoshop Lightroom" ) then
local presetFolderPath = LrPathUtils.parent( v:getPath() )
local presetFolderDirName = LrPathUtils.leafName( presetFolderPath )
Debug.pauseIf( presetFolderDirName ~= 'TEMPLATES', "not templates" )
local devModulePath = LrPathUtils.parent( presetFolderPath )
local devModuleDirName = LrPathUtils.leafName( devModulePath )
Debug.pauseIf( devModuleDirName ~= 'Develop.lrmodule', "not dev module" )
local lrAppFolderPath = LrPathUtils.parent( devModulePath )
local lrAppPath = LrPathUtils.child( lrAppFolderPath, WIN_ENV and 'lightroom.exe' or 'lightroom' ) -- ###1 test on Mac.
if fso:existsAsFile( lrAppPath ) then
return lrAppPath, lrAppFolderPath -- got it.
else
Debug.pause( "Hmm... - no Lr executable here:", lrAppPath )
end
end
end

This should work, unless user deleted all Lr factory default presets, in which case it pays to have a plan B.