rob_cole_2221866's profile

4.5K Messages

 • 

76.3K Points

Sun, Dec 1, 2013 11:41 PM

Closed

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

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.

4.5K Messages

 • 

76.3K Points

8 y ago

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.