For Current User:

  1. startup folder
    shell:startup

    create shortcut and autorun program in Windows_desktop

     

     
    create shortcut and autorun program in Windows_快捷方式_02

     

     create shortcut and autorun program in Windows_ico_03

     

     

  2. Registry

    create shortcut and autorun program in Windows_快捷方式_04

     

     

     

    create shortcut and autorun program in Windows_静态方法_05

     

     create shortcut and autorun program in Windows_desktop_06

     

     

     

For Local Machine:

  1. startup folder
    shell:common startup

    create shortcut and autorun program in Windows_.net_07

    create shortcut and autorun program in Windows_desktop_08

     

     

  2. Registry
    create shortcut and autorun program in Windows_静态方法_09

     

     create shortcut and autorun program in Windows_ico_10

     

     

 

Create shortcut:

  1. cmd
    create shortcut and autorun program in Windows_desktop_11

     

     create shortcut and autorun program in Windows_desktop_12

     

     create shortcut and autorun program in Windows_ico_13

     

     create shortcut and autorun program in Windows_ico_14

     

     create shortcut and autorun program in Windows_desktop_15

     

     

  2. powershell
    # 通过new-object(cmdlet)创建com对象,类是WScript.shell
    $com=new-object -ComObject WScript.shell
    # 使用.NET框架System.Environment类的GetFolderPath静态方法取得common folder路径(desktop,windows,system32)
    $destFolder=[System.Environment]::GetFolderPath("commonstartup")
    # 调用com对象CreateShortcut
    $shortcut=$com.CreateShortcut("$destFolder\vmware-tray.lnk")
    # 设置TargePath, IconLocation属性
    $shortcut.TargetPath="C:\Program Files (x86)\VMware\VMware Workstation\vmware-tray.exe"
    $shortcut.IconLocation="C:\Program Files (x86)\VMware\VMware Workstation\ico\generic.ico"
    # 调用save方法, 生成快捷方式
    $shortcut.save()