Skip to main content

Set-Shortcut

SYNOPSISโ€‹

Modifies a .lnk or .url type shortcut

SYNTAXโ€‹

Default (Default)โ€‹

Set-Shortcut [-Path] <String> [-TargetPath <String>] [-Arguments <String>] [-IconLocation <String>]
[-IconIndex <String>] [-Description <String>] [-WorkingDirectory <String>] [-WindowStyle <String>]
[-RunAsAdmin <Boolean>] [-Hotkey <String>] [-ContinueOnError <Boolean>] [<CommonParameters>]

Pipelineโ€‹

Set-Shortcut [-PathHash] <Hashtable> [-TargetPath <String>] [-Arguments <String>] [-IconLocation <String>]
[-IconIndex <String>] [-Description <String>] [-WorkingDirectory <String>] [-WindowStyle <String>]
[-RunAsAdmin <Boolean>] [-Hotkey <String>] [-ContinueOnError <Boolean>] [<CommonParameters>]

DESCRIPTIONโ€‹

Modifies a shortcut - .lnk or .url file, with configurable options.

Only specify the parameters that you want to change.

EXAMPLESโ€‹

EXAMPLE 1โ€‹

Set-Shortcut -Path "$envProgramData\Microsoft\Windows\Start Menu\My Shortcut.lnk" -TargetPath "$envWinDir\System32\notepad.exe" -IconLocation "$envWinDir\System32\notepad.exe" -IconIndex 0 -Description 'Notepad' -WorkingDirectory "$envHomeDrive\$envHomePath"

PARAMETERSโ€‹

-Pathโ€‹

Path to the shortcut to be changed

Type: String
Parameter Sets: Default
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-PathHashโ€‹

{{ Fill PathHash Description }}

Type: Hashtable
Parameter Sets: Pipeline
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-TargetPathโ€‹

Changes target path or URL that the shortcut launches

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Argumentsโ€‹

Changes Arguments to be passed to the target path

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-IconLocationโ€‹

Changes location of the icon used for the shortcut

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-IconIndexโ€‹

Change the index of the icon. Executables, DLLs, ICO files with multiple icons need the icon index to be specified. This parameter is an Integer. The first index is 0.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Descriptionโ€‹

Changes description of the shortcut

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WorkingDirectoryโ€‹

Changes Working Directory to be used for the target path

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WindowStyleโ€‹

Changes the Windows style of the application. Options: Normal, Maximized, Minimized, DontChange. Default is: DontChange.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: DontChange
Accept pipeline input: False
Accept wildcard characters: False

-RunAsAdminโ€‹

Set shortcut to run program as administrator. This option will prompt user to elevate when executing shortcut. If not specified or set to $null, the flag will not be changed.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Hotkeyโ€‹

Changes the Hotkey to launch the shortcut, e.g. "CTRL+SHIFT+F"

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ContinueOnErrorโ€‹

Continue if an error is encountered. Default is: $true.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: True
Accept pipeline input: False
Accept wildcard characters: False

CommonParametersโ€‹

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTSโ€‹

PSOjbectโ€‹

Path to the shortcut to be changed or a hashtable of parameters to be changedโ€‹

OUTPUTSโ€‹

Noneโ€‹

This function does not generate any output.โ€‹

NOTESโ€‹

Url shortcuts only support TargetPath, IconLocation and IconIndex. Other parameters are ignored.

https://psappdeploytoolkit.com