![create app shortcut create app shortcut](https://i1.wp.com/ateamfit.com/wp-content/uploads/2019/03/creating-mobile-shortcut-for-coaching-app-made-by-headliner_std.original.jpg)
Var startupFolderPath = Practice - Creating a Shortcut Key to Launch Apps Public static string CreateShortCutInStartUpFolder(string exeName, string startIn, string description) test.exe as found in the current directory / Creates a shortcut in the startup folder from a exe as found in the current directory. Here's a (Tested) Extension Method, with comments to help you out. Private static object InvokeMethod(this Type type, string methodName, object targetInstance, params object arguments)īindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, Private static object InvokeSetMember(this Type type, string methodName, object targetInstance, params object arguments)īindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty, Return Path.Combine(.StartupPath, linkFileName) ShortcutType.InvokeMethod("Save", shortcut) ShortcutType.InvokeSetMember("IconLocation", shortcut, iconLocation) ShortcutType.InvokeSetMember("Description", shortcut, description) ShortcutType.InvokeSetMember("WindowStyle", shortcut, shortcutWindowStyle) ShortcutType.InvokeSetMember("Hotkey", shortcut, hotkey) ShortcutType.InvokeSetMember("Arguments", shortcut, arguments) ShortcutType.InvokeSetMember("WorkingDirectory", shortcut, workingDirectory) ShortcutType.InvokeSetMember("TargetPath", shortcut, targetPath)
![create app shortcut create app shortcut](https://www.tech-recipes.com/wp-content/uploads/3.jpg)
Object shortcut = shellType.InvokeMethod("CreateShortcut", shell, linkFileName) Object shell = Activator.CreateInstance(shellType) Shortcut.WindowStyle = shortcutWindowStyle Shortcut.WorkingDirectory = workingDirectory Type shellType = Type.GetTypeFromProgID(WSCRIPT_SHELL_NAME) ĭynamic shell = Activator.CreateInstance(shellType) ĭynamic shortcut = shell.CreateShortcut(linkFileName) String FullName ", targetPath, iconNumber) Private static object m_shell = Activator.CreateInstance(m_type) Private static Type m_type = Type.GetTypeFromProgID("WScript.Shell") Without additional reference: using System Void SetRelativePath( string pszPathRel, int dwReserved) Void SetIconLocation( string pszIconPath, int iIcon) Void GetIconLocation( StringBuilder pszIconPath, int cchIconPath, out int piIcon) Void GetArguments( StringBuilder pszArgs, int cchMaxPath) Void SetWorkingDirectory( string pszDir) Void GetWorkingDirectory( StringBuilder pszDir, int cchMaxPath) Void GetDescription( StringBuilder pszName, int cchMaxName) Void GetPath( StringBuilder pszFile, int cchMaxPath, out IntPtr pfd, int fFlags) String desktopPath = Environment.GetFolderPath() įile.Save(Path.Combine(desktopPath, "MyLink.lnk"), false) IShellLink link = (IShellLink)new ShellLink()
#Create app shortcut code#
Here is a piece of code that has no dependency on an external COM object (WSH), and supports 32-bit and 64-bit programs: using System Here is an article that goes into detail what you need to do it, as well as sample code. If you want to use some API specific functions then you will want to use the IShellLink interface as well as the IPersistFile interface (through COM interop). Using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))Īpplication shortcut private void appShortcutToDesktop(string linkName) String deskDir = Environment.GetFolderPath() URL shortcut private void urlShortcutToDesktop(string linkName, string linkUrl)