Link to home
Start Free TrialLog in
Avatar of johnj_01201
johnj_01201

asked on

powershell need help executing command line program

I think it has to do with single and double quotes. I had the same problem using tiffcp.exe and it took me several days of trial and error to get it working. I was not able to get PDFtk working with variables:
What do you think?
thanks!


$input = 'one.PDF two.PDF'
$options = ' cat output '
$output = ' c:\temp\document.PDF'



#this works:
& pdftk.exe -version

#this does work:
&pdftk.exe one.PDF two.PDF cat output "c:\temp\document.PDF"


#this doesn't work:
& pdftk.exe $input cat output $output
ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnj_01201
johnj_01201

ASKER

Start-Process simply worked and solved the issue without needing to know how PS works internally. The $CommandLine method did not work and caused a giant sized error message containing dozens of XML errors and I do not know what it meant or where it came from. The points were divided because oBda's link provides great details on how PS runs command line programs and is something I really need to learn when I have more time. It also explains why it took me 3 days to get the previous command line program to work by messing with the double quotes and why the error message always shows a double quote (or two single quotes?) at the end of line that I could not figure out where in my code the extra quote was coming from. THANKS!