When running a program from PowerShell in the classic batch-like way - putting the program and its arguments plainly on a line - you might run in to trouble with characters that need escaping or quoting. PowerShell likes to interpret some characters as syntax directed at itself rather than as part of the command line for the new process. Attempting to quote problematic portions to stop PowerShell from parsing them may lead to undesirable quotes ending up in the command line.
A better solution is to use Start-Process, supplying one string with the command line to -ArgumentList. Since Start-Process is a cmdlet, it's very clear to PowerShell that it shouldn't mess with the syntax; the command is passed directly to the program.
No comments:
Post a Comment