![how to create lnk file how to create lnk file](https://fileinfo.com/img/help/shortcut-location-properties.png)
Here’s how to create a clickable link to a file on your network, using Outlook 2003 ( Update: This is much easier to do in Outlook 2007 and later-see the comments for different techniques): For whatever reason, we don’t want to send the actual file-it may be too big, we may not want the recipient to save it and work on it on their own machine, or similar. Those of us who have worked in-or continue to work in-networked offices often have to send a clickable hyperlink to a document stored on the company’s network.
HOW TO CREATE LNK FILE WINDOWS
The strings utility also reveals application compatibility with Windows Vista, 7, 8, 8.1 and 10.Microsoft Outlook’s Help is not much help when you are trying to create a clickable link to a file in your email message. icon-file (allows specifying the path to an icon file for the shortcut)Įxample usage: REM If bin folder already in your PATH, omit CD line:Ĭreate-shortcut.exe -work-dir "C:\path\to\files" -arguments "-myarg=myval" "C:\path\to\files\file.ext" "C:\path\to\shortcuts\shortcut.lnk" show-cmd (I presume this is the 'Run' droplist, values 'Normal window', 'Minimised', 'Maximised') arguments (tacked onto the end of the 'Target') exe, I was able to work out the and the mappings to the fields shown in shortcuts' Properties page: -work-dir ('Start in' field) However, using Sysinternals's strings utility to extract strings from the. This utility is not AFAICT publicly documented, and the -help is minimal: Usage: create-shortcut.exe If you have Git installed, it comes bundled with create-shortcut.exe which allows you to create shortcuts from the command line, and works in Windows 10. There are some additional attributes you can mangle through this object, too: Name MemberType DefinitionĪrguments Property string Arguments () You may have to explicity specify the path to PS in your file, but it should work. %PWS% -Command "$ws = New-Object -ComObject WScript.Shell $s = $ws.CreateShortcut(%SHORTCUT%) $S.TargetPath = %TARGET% $S.Save()" Set PWS=powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile Here's a similar solution using powershell (I know, you can probably re-write your whole batch file in PS, but if you just want to Get It Done™.) set TARGET='D:\Temp' SET Esc_LinkTarget=%%SYSTEMROOT%%\notepad.exeĮcho Set oWS = WScript.CreateObject^("WScript.Shell"^)Įcho sLinkFile = oWS.ExpandEnvironmentStrings^("!Esc_LinkDest!"^)Įcho Set oLink = oWS.CreateShortcut^(sLinkFile^)Įcho oLink.TargetPath = oWS.ExpandEnvironmentStrings^("!Esc_LinkTarget!"^) SET Esc_LinkDest=%%HOMEDRIVE%%%%HOMEPATH%%\Desktop\!LinkName!.lnk Here's a more complete snippet from an anonymous contributor (updated with a minor fix): off Running the above script results in a new shortcut on my desktop: For example, like so: offĮcho Set oWS = WScript.CreateObject("WScript.Shell") > CreateShortcut.vbsĮcho sLinkFile = "%HOMEDRIVE%%HOMEPATH%\Desktop\Hello.lnk" > CreateShortcut.vbsĮcho Set oLink = oWS.CreateShortcut(sLinkFile) > CreateShortcut.vbsĮcho oLink.TargetPath = "C:\Windows\notepad.exe" > CreateShortcut.vbs So, if you really must do it, then you could make your batch file write the VB script to disk, invoke it and then remove it again. ' oLink.WorkingDirectory = "C:\Program Files\MyApp" ' oLink.IconLocation = "C:\Program Files\MyApp\MyProgram.EXE, 2" OLink.TargetPath = "C:\Program Files\MyApp\MyProgram.EXE" Set oLink = oWS.CreateShortcut(sLinkFile) Optional sections in the VBscript below are commented out: Set oWS = WScript.CreateObject("WScript.Shell") Seems like there is some shortcut.exe in some resource kit which I don't have.Īs many other sites mention, there is no built-in way to do it from a batch file. There is some very useful information on this site: