Copy file to photoshop directory using batch file

I am trying to modify a script package that installs a simple script file in the photoshop user directory.

The main installation process is to copy most of the product files to the% APPDATA% folder, after which this batch of script runs post-install, which copies the small script hook into Photoshop \ presets \ scripts. However, we ran into problems with% APPDATA% that are not defined on some client computers, it would be bad practice to check if it exists, and then install it if not, and if not, how would you best configure its accounting for different versions of Windows

I also made a rather bumpy trip along the “reg query” road to try to find the serial key that Photoshop installs to find the “Path”, which is the installation directory, but I wonder what better practices are for this too.

Here is my current working version having some relics of vista permissions p>

    @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 does not exist, the current solution, deployed only by brute force, is trying to install any known place for Photoshop (based on% PROGRAMFILES% /% PROGRAMFILES (x86)%. To a more reliable and consistent version of the script, as well as to any Tips on which installer products might work best for deploying this type of script in a cross-platform manner (mainly Mac / Windows).

+3
1

, , , Inno setup. . pascal, , , . -, , python api!

( , ), , /, , - .

, , 2 2 , 32- 64- . , photoshop, . , " " . , , Adobe, . , , , , , , ( , ), !

0

Source: https://habr.com/ru/post/1749073/


All Articles