Resources for IT Professionals > Página Inicial dos Fóruns > Windows PowerShell > How to create shortcut in startup menu using powershell?
Fazer uma PerguntaFazer uma Pergunta
 

RespondidoHow to create shortcut in startup menu using powershell?

  • segunda-feira, 29 de junho de 2009 18:53Leonjl Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    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

Respostas

  • segunda-feira, 29 de junho de 2009 21:04Vadims PodansMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     RespondidoContém Código
    $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

Todas as Respostas

  • segunda-feira, 29 de junho de 2009 19:18Marco ShawMVP, ModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    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?
  • segunda-feira, 29 de junho de 2009 21:04Vadims PodansMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     RespondidoContém Código
    $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
  • terça-feira, 30 de junho de 2009 20:40MozillaKilled Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    I think you can do this with the PSCX  extensions package.
  • quinta-feira, 2 de julho de 2009 3:36Mervyn ZhangMSFT, ModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    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.