none
Tried to get the path to a certain .ink file. RRS feed

  • Question

  • Hi,

    I try to get to path to a certain .ink file. Get no error but doensn't work either

     $sh = New-Object -ComObject WScript.Shell
    $target = $sh.CreateShortcut("$env:appdata + xxxxxx\xxxxxxx\xxxxxxx\xxxxxxx\xxxxxxx\xxxxxxx.lnk").TargetPath

    P

    Monday, February 11, 2019 5:18 PM

Answers

  • You should determine the desired name of the file "outside" of the target method ...  maybe like this:

    $LinkFile = Get-ChildItem -Path $env:APPDATA -Recurse -File -Filter 'name of the file.lnk' | Select-Object -ExpandProperty FullName


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    • Marked as answer by PeetK Monday, February 11, 2019 5:39 PM
    Monday, February 11, 2019 5:33 PM

All replies

  • You should determine the desired name of the file "outside" of the target method ...  maybe like this:

    $LinkFile = Get-ChildItem -Path $env:APPDATA -Recurse -File -Filter 'name of the file.lnk' | Select-Object -ExpandProperty FullName


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    • Marked as answer by PeetK Monday, February 11, 2019 5:39 PM
    Monday, February 11, 2019 5:33 PM
  • Don't you think you should start with learning the very basics of Powershell. You are asking beginner questions. Every book or tutorial would answer this kind of questions in the first chapters.

    As long as it's still available you could start with this: Microsoft Virtual Academy - Getting Started with Microsoft PowerShell.

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Monday, February 11, 2019 5:36 PM