public static void CreateShortcut(ShortcutUnit Shortcut) { String IconPath = Path.GetFullPath( Shortcut.IconLocation ); String Target = Path.GetFullPath( Shortcut.TargetPath ); WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut( Shortcut.LinkName ); shortcut.TargetPath = Shortcut.TargetPath; shortcut.WindowStyle = 1; shortcut.IconLocation = Shortcut.IconLocation; shortcut.Description = Shortcut.Description; //Set up this propertise, the "current location" would be the application folder, //rather than the location of shortcut. shortcut.WorkingDirectory = Path.GetDirectoryName( Target ); shortcut.Save(); }
private void Init_CreateShortcuts() { ShortcutUnit[] shortcutList = new ShortcutUnit[] { new ShortcutUnit( AppSetting.Shortcut_Desktop , AppSetting.AppFullPath , AppSetting.App_IconPath , AppSetting.Description ) , new ShortcutUnit( AppSetting.Shortcut_SendTo , AppSetting.AppFullPath , AppSetting.App_IconPath , AppSetting.Description ) , new ShortcutUnit( AppSetting.Shortcut_StartMenu , AppSetting.AppFullPath , AppSetting.App_IconPath , AppSetting.Description ) , new ShortcutUnit( AppSetting.Shortcut_NetworkShortcuts , AppSetting.AppFullPath , AppSetting.App_IconPath , AppSetting.Description ) , new ShortcutUnit( AppSetting.Shortcut_Links , AppSetting.AppFullPath , AppSetting.App_IconPath , AppSetting.Description ) , }; foreach ( ShortcutUnit scu in shortcutList ) { if(!File.Exists(scu.LinkName)) ShortcutHelper.CreateShortcut( scu ); } }