# Custom Post-Imaging Actions (PSImage)

<p class="callout danger">PSImage is not supported by FileWave Support, so support tickets should not be opened for it. The information provided here is for educational purposes only. For paid help setting up or customizing PSImage, contact <professional.services@filewave.com>. Existing unused Professional Services hours may also be usable for this work. Feedback on PSImage can go to the same address. Work on PSImage happens through Discord or Professional Services. For the official Windows Imaging solution, see Network Imaging / IVS.</p>

PSImage includes post-imaging actions for the imaging workflow. The to\_do.bat file in the scripts folder of the psimage share runs those actions with admin privileges under the temporary local fwadmin account. FileWave deletes that account at the end of the post-imaging phase. You can add custom post-imaging actions in two ways:

1. The contents of the extra folder in the psimage share is copied to c:\\windows\\temp\\psimage. Place any files/folders here that you want to be copied to the reimaged PC and run during the post-imaging phase. The c:\\windows\\temp\\psimage folder will be deleted automatically from the reimaged PC at the end of the post-imaging phase.
2. Use the to\_do.bat file in the scripts folder of the psimage share to trigger any built-in Windows utilities or executables/installers that have been copied to c:\\windows\\temp\\psimage. Note that the post-imaging phase does not have access to the psimage share but only to the files copied to c:\\windows\\temp\\psimage. If there are any commands that must be run or apps that must be installed immediately after reimaging, add them to the extra folder and trigger them via to\_do.bat as necessary.

Follow the tips in the sample to\_do.bat when launching apps. The post-imaging phase reboots at the end, so use "start /wait", especially for installers, to make to\_do.bat wait before moving to the next command. Otherwise the system may reboot before the installer finishes. If you need to deploy files to the reimaged PC, include them in the disk image or copy them from c:\\windows\\temp\\psimage. Do not move them; the sample to\_do.bat explains why.

```bash
REM Copy files from psimage folder to their intended locations instead of moving them so they inherit security
REM permission from the existing parent folder. Otherwise the owner will be system account and no users will be able to
REM access the files.
REM
REM If adding registry settings with reg add with a value that includes spaces and double quotes in it, add 
REM outer quotes (to maintain the spaces) and backslash escape the inner quotes to maintain them in the registry
REM value.
REM reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v bginfo /t REG_SZ /d "\"C:\Program Files\bginfo\Bginfo64.exe\" \"C:\Program Files\bginfo\config.bgi\" /timer:0 /silent /nolicprompt"
REM
REM If launching an executable use start /wait so the script waits for your binary to finish before rebooting. 
REM If the commandline includes spaces use start /wait "" <your_command_line>.
REM start /wait "" "c:\windows\temp\psimage\Firefox Setup 88.0.1.exe" /S
REM 
REM For logging redirect the output for your commands with >> c:\windows\temp\psimage.log
REM start /wait "" "c:\windows\temp\psimage\Firefox Setup 88.0.1.exe" /S >> c:\windows\temp\psimage.log
REM
REM To redirect both stderr and stdout for your commands use >> c:\windows\temp\psimage.log 2>&1
REM start /wait "" "c:\windows\temp\psimage\Firefox Setup 88.0.1.exe" /S >> c:\windows\temp\psimage.log 2>&1
REM
REM ========ENTER YOUR POST-IMAGING COMMANDS BELOW========

echo Running to_do.bat >> c:\windows\temp\psimage.log

```