Triple quote with a variable?

Welcome Forums General PowerShell Q&A Triple quote with a variable?

This topic contains 2 replies, has 2 voices, and was last updated by

1 year, 9 months ago.

  • Author
  • #70615

    Points: 0
    Rank: Member

    I'm having issues making ArugmentList on Start-Process respect special characters and my google fu is failing me.

    This script block works fine

    Start-Process .\process.exe -ArgumentList """D:\Folder\[] Derp.txt"""

    But I cannot find a way to make it work with $FileName instead of D:\Folder\[] Derp.txt

  • #70619

    Points: 502
    Helping Hand
    Rank: Major Contributor

    A couple of things. If you look at the documentation for Start-Process, ArgumentList is a string array (string[]). Second, when you use double qoutes, Powershell will attempt to resolve that string and expand variables, etc. versus single qoutes are literal.

    Try this:

    $path = "D:\Folder\[]"
    $fileName = "Derp.txt"
    Start-Process .\process.exe -ArgumentList $path, $fileName

    If that still doesn't work, try changing the double qoutes to single qoutes to basically force Powershell to treat the variables as strings.

    • #70795

      Points: 0
      Rank: Member

      Thanks for the response! I'll give this a shot tonight.

The topic ‘Triple quote with a variable?’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort