I wrote a powershell script file that takes a bool parameter. I also have a windows shortcut for this powershell script. The problem is that whenever I try to run a script from a shortcut, the parameter is interpreted as a string, not a bool, but the script crashes.
This is what I originally posted in the target section of my shortcut:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" $true
I searched for solutions on the Internet and also tried the following options:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" -copyAll:$true C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" -copyAll:`$$true C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" "`$$true" C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" `$$true
And a few of these variations.
This is my question for you: is there a way to send the value of the bool parameter to a script when running a from a Windows shortcut?
source share