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
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
You can use the INTERNAL command MKLINK
to make a SYMBOLIC link (ie: It acts just like the file it's linked to).
You need to have an elevated command prompt, or have the Administrator account activated (with a password set, as RUNAS
will not accept a blank password).
From an elevated command prompt:
mklnk.bat
@echo off
mklink %~n1.lnk %~dpnx1
With an active Administrator account:
mklnk.bat
@echo off
runas /user:administrator "cmd /c mklink %~dpn1.lnk %~dpnx1"
Because mklink
is an internal command, you can't use RUNAS
to directly access it, but you can run CMD.EXE
as the Administrator, and then call mklink
from there.
Both of the above batch files will accept the same options and create the same files in the same place. So if you call the batch file mklnk.bat
:
c:>mklnk welcome.msg
symbolic link created for welcome.lnk <<===>> welcome.msg
Another CMD.EXE
window will flash on the screen, but that is normal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With