views:

117

answers:

1

Hi, I am trying to modify a batch script that installs a simple script file into the users photoshop directory.

The basic process of the installer is to copy the bulk of the products files into the %APPDATA% folder, then this batch script runs post-install that copies a little hook script into photoshop\presets\scripts. However we've run into issues with %APPDATA% not being defined on some customers machines, would it be bad practice to check if it exist then set it if not, and if not how would you best set it accounting for different versions of Windows?

I've also taken a pretty bumpy ride down the 'reg query' road to try and find a consistent key that photoshop sets in order to find the "Path" which is the install directory but I'm wondering what the best-practices for that are as well.

Here's my current working version that has some vista permission relics

    @echo off
rem | locate photoshop by querying the registry
echo Locating your photoshop installation..
set regpath="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Photoshop.exe"
set regval="Path"
set photoshop_path=

rem | accumlate the path from the query
for /f "tokens=2,* delims= " %%A in ('reg query %regpath% /v %regval%') do ( 
    set photoshop_path=%%B 
)

rem | get rid of the last hanging space
set photoshop_path=%photoshop_path:~0,-1%

echo found photoshop at %photoshop_path%

set script_path=%photoshop_path%Presets\Scripts\script.jsx

echo Removing existing copies of script.jsx..
if exist "%script_path%" del "%script_path%"
echo ...Done!

echo Installing script.jsx to Photoshop Scripts directory... %script_path%
if exist "%photoshop_path%Photoshop.exe copy "%APPDATA%\My Company\etc\script.jsx" "%script_path%"
echo Done!

rem | some fix for vista permissions
ver | find "XP" > nul
if %ERRORLEVEL% neq 0 goto exit

echo Setting permissions for Vista...
echo ...Taking ownership of files...
takeown /f "%APPDATA%\My Company" /r /d y
echo ...Granting write access to files...
icacls "%APPDATA%\My Company" /grant Users:F /t
echo Done!

:exit

echo Creating Product Library entry in folderlist.cfg
echo Product Library=%APPDATA%\My Company\library>>"%APPDATA%\My Company\etc\folderlist.cfg"
echo Done!

However, problems arise when the key doesn't exist, the current solution that is deployed just brute force tries every known location photoshop might be installed (based on the %PROGRAMFILES%/%PROGRAMFILES(x86)% variables. Any help towards a more robust and consistent script is much appreciated as well as any advice on what installer products might work best for deploying this type of script in a cross-platform manner(Mac/Windows mostly).

A: 

Well, I basically solved this problem by writing a completely new installer using Inno setup. It rocks. It uses pascal which feels a little archaic to me but it was much easier to pickup and use than batch scripting. Somebody please write a python installer api!

As far as best practices go for locating a user's installation of photoshop(or any program for that matter), it seems like the brute force method of simply trying every possible key/directory it might be located in is the best bet.

For instance, when I installed photoshop recently, it actually gave me 2 installations in 2 separate folders, a 32 bit and 64 bit version. Ideally, when I run my installer to add things to photoshop's directory, it should go into both versions. It wouldn't do that if I simply queried some 'master registry key' and stuffed it in there. It seems that, over the years, even a big name like Adobe hasn't used the registry in a consistent manner. So, the best chance my installer has of working is making a big list of every possible registry key adobe has made for the installation path of photoshop and trying all of them, and then also trying raw directories myself (based on environment variables at least). If only people followed standards!

Tom