Bat file to create a Windows 7 shortcut.lnk on my desktop

Jay picture Jay · Oct 26, 2012 · Viewed 24.4k times · Source

How can I create a bat or vbs file to create a Windows 7 compatible desktop shortcut?

I need the bat or vbs file to create the desktop shortcut using the following target and start-in locations (below). I basically created a desktop app that uses Google Chrome Portable to render my webapp as if it is Windows native and the shortcut will launch Chrome so it is very lightweight and looks like a genuine Windows application kinda like what Prism used to do. I've tried manually creating the shortcut.lnk but when my user installs my app it wont extract my shortcut.lnk via this path C:\Users\Public\Desktop so thats why I am now trying to create a bat or vbs file I can run on install. Thanks for your help.

Target:

C:\MyProgram\App\Chrome-bin\chrome.exe --user-data-dir="C:\MyProgram\Data\profile" --app=http://my-web-site-url.com/

Start in:

C:\MyProgram\App\Chrome-bin

Answer

Alex K. picture Alex K. · Oct 26, 2012

Your installer should be able to do this ... here is how in VBS:

Set wsc = WScript.CreateObject("WScript.Shell")
Set lnk = wsc.CreateShortcut(wsc.SpecialFolders("desktop") & "\XXXX.LNK")

lnk.targetpath = "C:\MyProgram\App\Chrome-bin\chrome.exe"
lnk.arguments = "--user-data-dir=""C:\MyProgram\Data\profile"" --app=http://my-web-site-url.com/"
lnk.description = "Bla bla"
lnk.workingdirectory = "C:\MyProgram\App\Chrome-bin" 
lnk.save