IT 专业人士的资源 > 论坛主页 > Windows PowerShell > How to create shortcut in startup menu using powershell?
提出问题提出问题
 

已答复How to create shortcut in startup menu using powershell?

  • 2009年6月29日 18:53Leonjl 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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

答案

  • 2009年6月29日 21:04Vadims PodansMVP用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复包含代码
    $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

全部回复

  • 2009年6月29日 19:18Marco ShawMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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?
  • 2009年6月29日 21:04Vadims PodansMVP用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复包含代码
    $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
  • 2009年6月30日 20:40MozillaKilled 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    I think you can do this with the PSCX  extensions package.
  • 2009年7月2日 3:36Mervyn ZhangMSFT, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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.