Windows Server TechCenter > Windows Server Forums > Windows PowerShell > How to create shortcut in startup menu using powershell?
Ask a questionAsk a question
 

AnswerHow to create shortcut in startup menu using powershell?

  • Monday, June 29, 2009 6:53 PMLeonjl Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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

Answers

  • Monday, June 29, 2009 9:04 PMVadims PodansMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas 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

All Replies

  • Monday, June 29, 2009 7:18 PMMarco ShawMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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?
  • Monday, June 29, 2009 9:04 PMVadims PodansMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas 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
  • Tuesday, June 30, 2009 8:40 PMMozillaKilled Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I think you can do this with the PSCX  extensions package.
  • Thursday, July 02, 2009 3:36 AMMervyn ZhangMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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.