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).