I have a Powershell script that retrieves all image files (.jpg, .png) from a folder on a server and "prints" them to a file, specifically a .prn file using a specific print driver. All of that works fine. The issue is that I can't work out how to control where the output of "printing" goes, i.e. where it puts the resulting .prn file. They always go to the Pictures folder on my PC. I''d like for them to be placed into the same server folder from which the input images came from. Over that last week I've search every combination of Powershell out-print, out-file etc that I can think to try but no luck finding a solution so far. Any help would be appreciated. Here is my current script.
$VerbosePreference = "Continue"
add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
$newext = ".prn"
$Directory = "\\192.168.30.46\resource\Item\"
$files = Get-ChildItem -Path $Directory –File
$focus = 2000
for ($i=0; $i -lt 5; $i++) {
$newfile = $files[$i].BaseName + $newext
Start-Process $files[$i].FullName -verb Print | out-printer -name "Page Segment Print File"
start-sleep -Milliseconds $focus
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
start-sleep -Milliseconds 250
[System.Windows.Forms.SendKeys]::SendWait($newfile)
start-sleep -Milliseconds 250
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
start-sleep -Milliseconds 1500
$focus = 250
}
Write-Verbose "Print Files Generated"