Saltar al contenido principal

Shortcuts class

Namespace: Velopack.Windows

Deprecated

Desktop and StartMenuRoot shortcuts are now created and removed automatically when your app is installed / uninstalled.

A helper class to create or delete windows shortcuts.

[Obsolete("Desktop and StartMenuRoot shortcuts are now created and removed automatically when your app is installed / uninstalled.")]
public class Shortcuts

Constructors

ConstructorSummary
ShortcutsA helper class to create or delete windows shortcuts.

Shortcuts(locator)

public Shortcuts(IVelopackLocator locator = null)

A helper class to create or delete windows shortcuts.

Parameters

NameTypeDescription
locatorIVelopackLocator

Properties

PropertySummary
LogLog for diagnostic messages.
LocatorLocator to use for finding important application paths.

Log

protected IVelopackLogger Log { get; }

Log for diagnostic messages.

Locator

protected IVelopackLocator Locator { get; }

Locator to use for finding important application paths.

Methods

MethodSummary
CreateShortcutForThisExeCreate a shortcut to the currently running executable at the specified locations.
RemoveShortcutForThisExeRemoves a shortcut for the currently running executable at the specified locations
FindShortcutsSearches for existing shortcuts to an executable inside the current package.
CreateShortcutCreates new shortcuts to the specified executable at the specified locations.
DeleteShortcutsDelete all the shortcuts for the specified executable in the specified locations.
LinkPathForVersionInfoGiven an ZipPackage and FileVersionInfo return the target shortcut path.
GetLinkPathGiven the application info, return the shortcut target path.

CreateShortcutForThisExe(location)

public void CreateShortcutForThisExe(ShortcutLocation location = ShortcutLocation.Desktop | ShortcutLocation.StartMenuRoot)

Create a shortcut to the currently running executable at the specified locations. See CreateShortcut to create a shortcut to a different program

Parameters

NameTypeDescription
locationShortcutLocation

RemoveShortcutForThisExe(location)

public void RemoveShortcutForThisExe(ShortcutLocation location = ShortcutLocation.StartMenu | ShortcutLocation.Desktop | ShortcutLocation.StartMenuRoot)

Removes a shortcut for the currently running executable at the specified locations

Parameters

NameTypeDescription
locationShortcutLocation

FindShortcuts(relativeExeName, locations)

public Dictionary<ShortcutLocation, ShellLink> FindShortcuts(string relativeExeName, ShortcutLocation locations)

Searches for existing shortcuts to an executable inside the current package.

Parameters

NameTypeDescription
relativeExeNamestringThe relative path or filename of the executable (from the current app dir).
locationsShortcutLocationThe locations to search.

Returns Dictionary<ShortcutLocation, ShellLink>

CreateShortcut(relativeExeName, locations, updateOnly, programArguments, icon)

public void CreateShortcut(string relativeExeName, ShortcutLocation locations, bool updateOnly, string programArguments, string icon = null)

Creates new shortcuts to the specified executable at the specified locations.

Parameters

NameTypeDescription
relativeExeNamestringThe relative path or filename of the executable (from the current app dir).
locationsShortcutLocationThe locations to create shortcuts.
updateOnlyboolIf true, shortcuts will be updated instead of created.
programArgumentsstringThe arguments the application should be launched with
iconstringPath to a specific icon to use instead of the exe icon.

DeleteShortcuts(relativeExeName, locations)

public void DeleteShortcuts(string relativeExeName, ShortcutLocation locations)

Delete all the shortcuts for the specified executable in the specified locations.

Parameters

NameTypeDescription
relativeExeNamestringThe relative path or filename of the executable (from the current app dir).
locationsShortcutLocationThe locations to create shortcuts.

LinkPathForVersionInfo(location, package, versionInfo, rootdir)

protected virtual string LinkPathForVersionInfo(ShortcutLocation location, ZipPackage package, FileVersionInfo versionInfo, string rootdir)

Given an ZipPackage and FileVersionInfo return the target shortcut path.

Parameters

NameTypeDescription
locationShortcutLocation
packageZipPackage
versionInfoFileVersionInfo
rootdirstring

Returns string

GetLinkPath(location, title, applicationName, rootdir, createDirectoryIfNecessary)

protected virtual string GetLinkPath(ShortcutLocation location, string title, string applicationName, string rootdir, bool createDirectoryIfNecessary = true)

Given the application info, return the shortcut target path.

Parameters

NameTypeDescription
locationShortcutLocation
titlestring
applicationNamestring
rootdirstring
createDirectoryIfNecessarybool

Returns string


Generated from Velopack 1.1.1