creating a shortcut for a exe from a batch file

后端 未结 9 1545
清酒与你
清酒与你 2020-11-27 05:39

how to create a shortcut for a exe from a batch file.

i tried

call link.bat \"c:\\program Files\\App1\\program1.exe\" \"C:\\Documents and Settings\\         


        
9条回答
  •  盖世英雄少女心
    2020-11-27 06:22

    Using vbscript:

    set WshShell = WScript.CreateObject("WScript.Shell" )
    strDesktop = WshShell.SpecialFolders("AllUsersDesktop" )
    set oShellLink = WshShell.CreateShortcut(strDesktop & "\shortcut name.lnk" )
    oShellLink.TargetPath = "c:\application folder\application.exe"
    oShellLink.WindowStyle = 1
    oShellLink.IconLocation = "c:\application folder\application.ico"
    oShellLink.Description = "Shortcut Script"
    oShellLink.WorkingDirectory = "c:\application folder"
    oShellLink.Save 
    

    Ref: http://www.tomshardware.com/forum/52871-45-creating-desktop-shortcuts-command-line

    Failing that, a quick google search shows there's a number of third party tools that can create .lnk files for application shortcuts. I'm assuming you need to stick to stuff that's available natively on Windows though? VBscript is probably your best bet, otherwise I'd suggest trying copying the .lnk file from your machine or using it as a sample to see the correct format for a shortcut file.

提交回复
热议问题