Windows 10: How to programmatically create a desktop shortcut link via Powershell or batch file command...

Discus and support How to programmatically create a desktop shortcut link via Powershell or batch file command... in Microsoft Windows 10 Store to solve the problem; Currently the *.appxbundle installs into the StartMenu, which is fine, but I'd also like to include a shortcut link on the destkop. I see from this... Discussion in 'Microsoft Windows 10 Store' started by soulmate75, Mar 8, 2021.

  1. How to programmatically create a desktop shortcut link via Powershell or batch file command...


    Currently the *.appxbundle installs into the StartMenu, which is fine, but I'd also like to include a shortcut link on the destkop.


    I see from this link that it's possible to create a short-cut manually for a sideloaded or Windows Store application.

    https://www.thurrott.com/windows/windows-10/5328/windows-10-tip-create-shortcuts-for-universal-apps


    So how can I automate the steps from the above article?

    More specifically how can I find out what is the unique identifier Windows uses to create that shortcut?



    Thanks!

    :)
     
    soulmate75, Mar 8, 2021
    #1
  2. Flava0ne Win User

    Creating Shortcuts with Batch File

    Tried both of the VB Scripts that you provided and adding the 9 switch to the batch file but neither was able to create a shortcut to my desktop.
     
    Flava0ne, Mar 8, 2021
    #2
  3. Flava0ne Win User
    Creating Shortcuts with Batch File

    I've created a Batch file which calls on the following VB Script to be able to create a shortcut to my desktop:

    VB Script (named createLink.vbs):
    Code: set objWSHShell = CreateObject("WScript.Shell") set objFso = CreateObject("Scripting.FileSystemObject") ' command line arguments ' TODO: error checking sShortcut = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(0)) sTargetPath = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(1)) sWorkingDirectory = objFso.GetAbsolutePathName(sShortcut) set objSC = objWSHShell.CreateShortcut(sShortcut) objSC.TargetPath = sTargetPath objSC.WorkingDirectory = sWorkingDirectory objSC.Save[/quote] Batch File Example (for Windows Notepad):
    Code: @Echo off cscript createLink.vbs "C:\Users\Administrator\Desktop\Notepad.lnk" "C:\Windows\System32\notepad.exe"[/quote] But after creating the shortcut using this method, I'm not able to assign a custom icon for the shortcut. I get the following error message when trying to do so:


    How to programmatically create a desktop shortcut link via Powershell or batch file command... Error503.jpg


    Any help and ideas on what I need to put into the VB Script and/or Batch File to be able to do this would be greatly appreciated! *Big Grin How to programmatically create a desktop shortcut link via Powershell or batch file command... :D

    Also, I know that I can simply do this by going to Start Menu\All Programs\Accessories\ right-clicking on Notepad and selecting Send to\Desktop (create shortcut). Easy enough for creating a single shortcut. But I need to create several multiple shortcuts and using this Batch/VBS method would really save me a lot of time in doing so.
     
    Flava0ne, Mar 8, 2021
    #3
  4. How to programmatically create a desktop shortcut link via Powershell or batch file command...

    Creating Shortcuts with Batch File

    Hmm, I just tried it and it worked fine. Maybe try running the batch as administrator? Also, right click on the desktop after the shortcut is created and click Refresh.

    If the file in the third parameter doesn't exist, it assumes the icon is in the application.
     
    FordGT90Concept, Mar 8, 2021
    #4
Thema:

How to programmatically create a desktop shortcut link via Powershell or batch file command...

Loading...
  1. How to programmatically create a desktop shortcut link via Powershell or batch file command... - Similar Threads - programmatically create desktop

  2. Screen switching via batch/powershell file possible?

    in Windows 10 Gaming
    Screen switching via batch/powershell file possible?: Hi, I have three screens connected to my PC, 1 x TV and 2 x TFT's.I'd like to be able to automatically switch between different screens as being primary whilst disabling the others via double click on, perhaps, a batch file.Essentially I would like to be able to have three...
  3. Screen switching via batch/powershell file possible?

    in Windows 10 Software and Apps
    Screen switching via batch/powershell file possible?: Hi, I have three screens connected to my PC, 1 x TV and 2 x TFT's.I'd like to be able to automatically switch between different screens as being primary whilst disabling the others via double click on, perhaps, a batch file.Essentially I would like to be able to have three...
  4. How to batch-resolve file shortcuts turn shortcuts into the files they link to ?

    in Windows 10 Network and Sharing
    How to batch-resolve file shortcuts turn shortcuts into the files they link to ?: Hi! I'm considering to use file shortcuts lnk files for my documents in order to allow a single file to occur in multiple folders - as a real file in one folder and as file shortcuts in other folders. However, I will have to export folders with many of these file...
  5. run a powershell command like a batch file

    in Windows 10 Installation and Upgrade
    run a powershell command like a batch file: I am working as a temp on a Windows 7 to Windows 10 migration team. We've encountered a problem with some software, and a solution has been found that requires us to execute a a single command with PowerShell. However, the command is extremely long and complex, and very...
  6. Creating Keyboard Shortcut via Batch

    in Windows 10 Ask Insider
    Creating Keyboard Shortcut via Batch: I want to create my own tool for Windows 10. The plan is to run it by pressing (For example) the "F4" key. I am aware, that I can just configure it to run over the gui, but for easier setup I would greatly appreciate it to set up the shortcut via a command. Does anybody...
  7. Create batch files with Batch?

    in Windows 10 Software and Apps
    Create batch files with Batch?: How to create Batch and VBS files with Batch? So I write a batch file which I then convert to exe that creates new folders in a certain directory and then creates batch and VBS files with a certain content and saves them in the created folder. So it's similar to a program...
  8. how to add powershell batch file shortcut to taskbar

    in Windows 10 Support
    how to add powershell batch file shortcut to taskbar: Hi I have several batch files which I've created shortcuts for, and added to my windows taskbar. I now have a new batch file which contains some powershell which instructs pc to switch off screen. Please can anyone advise why Windows won't let me place this shortcut on the...
  9. how to add powershell batch file shortcut to taskbar

    in Windows 10 Performance & Maintenance
    how to add powershell batch file shortcut to taskbar: Hi I have several batch files which I've created shortcuts for, and added to my windows taskbar. I now have a new batch file which contains some powershell which instructs pc to switch off screen. Please can anyone advise why Windows won't let me place this shortcut on the...
  10. How to run batch file with powershell

    in Windows 10 Network and Sharing
    How to run batch file with powershell: I created a basic batch file that uses "net share" to share a local path. I saved the batch file. When I double click the file I get "access is denied"... note, I am logged on as a admin. Anyways... I figure it has to be run using power shell. I do not know much about...