Ressourcen für IT-Professionals > Forenhomepage > Windows PowerShell > How to create shortcut in startup menu using powershell?
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetHow to create shortcut in startup menu using powershell?

  • Montag, 29. Juni 2009 18:53Leonjl TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hi,

    Can anybody tell me how to create shortcut in startup menu using powershell?

    I found some samples about how to do this using VBS but I prefer powershell. :)

    Thanks
    Leon

Antworten

  • Montag, 29. Juni 2009 21:04Vadims PodansMVPTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     BeantwortetEnthält Code
    $objShell = New-Object -ComObject ("WScript.Shell")
    $objShortCut = $objShell.CreateShortcut($env:USERPROFILE + "Start Menu\Programs\Startup" + "\program.lnk")
    $objShortCut.TargetPath("path to program")
    $objShortCut.Save()
    this will create link from scratch.
    [тут могла быть ваша реклама] http://www.sysadmins.lv

Alle Antworten

  • Montag, 29. Juni 2009 19:18Marco ShawMVP, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    I think these are typically .lnk files.  I don't think PowerShell can easily create these...  Unless you have an existing .lnk file, and you simply want to copy it to a new folder, you may need to refer to the VBS code.

    It possibly uses WScript, and you may want to use an interface to WScript for this...

    So the important question is...  Do you already have an .lnk file, and just need to copy it? Or do you need something from scratch?
  • Montag, 29. Juni 2009 21:04Vadims PodansMVPTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     BeantwortetEnthält Code
    $objShell = New-Object -ComObject ("WScript.Shell")
    $objShortCut = $objShell.CreateShortcut($env:USERPROFILE + "Start Menu\Programs\Startup" + "\program.lnk")
    $objShortCut.TargetPath("path to program")
    $objShortCut.Save()
    this will create link from scratch.
    [тут могла быть ваша реклама] http://www.sysadmins.lv
  • Dienstag, 30. Juni 2009 20:40MozillaKilled TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    I think you can do this with the PSCX  extensions package.
  • Donnerstag, 2. Juli 2009 03:36Mervyn ZhangMSFT, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hi,

    Detailed explanation for Vadims script:

    http://www.microsoft.com/technet/scriptcenter/topics/winpsh/convert/wshsave.mspx

    Thanks.

    This posting is provided "AS IS" with no warranties, and confers no rights.