I want to print a PNG file from within a PowerShell script. I can make it work by inserting the full path to the image, but I want it to be variable.
This works:
Start-Process -filepath "C:\windows\system32\mspaint.exe" -argumentlist '/p "D:\simplecodegenerator\5555.png" /pt "Microsoft Print to PDF"'
But I cannot get it to work with variables.
$photo = "5555.png"
$folder = "D:\simplecodegenerator\"
Start-Process -filepath "C:\windows\system32\mspaint.exe" -argumentlist '/p $folder$photo /pt "Microsoft Print to PDF"'
When I run the last code it will give the following error:
C:\Users\*******\$folder$photo.png not found. I was expecting that it would save as D:\simplecodegenerator\5555.png
Can anybody help me with this, or is it impossible to do ?