Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Creating Shortcut .lnk/.url files

Reply
 
Old 11-29-2006   #1 (permalink)
Jason Gurtz


 
 

Creating Shortcut .lnk/.url files

I was hoping that some kind of 'New-Item -Type "Shortcut"' invocation
would do, but apparently not.

Is there any way to create shortcuts in PS without using the legacy WSH
CreateShortcut method?

Specifically, this legacy method does not allow for setting the icon on
web (.url) shortcuts, even though you can do that through the GUI.
Maybe WMI has a better way?

~Jason

--

My System SpecsSystem Spec
Old 12-01-2006   #2 (permalink)
fixitchris


 
 

RE: Creating Shortcut .lnk/.url files

Not PS, but might help...

Shortcut [Version 1.11]

Creates, modifies or queries Windows shell links (shortcuts)


The syntax of this command is:

Shortcut.exe /F:filename /A:C|E|Q [/T:target] [/Parameters] [/W:workingdir]
[/R:runstyle] [/I:icon,index] [/H:hotkey] [/D:description]

/F:filename : Specifies the .LNK shortcut file.
/A:action : Defines the action to take (C=Create, E=Edit or Q=Query).
/T:target : Defines the target path and file name the shortcut points
to.
/Parameters : Defines the command-line parameters to pass to the target.
/W:working dir : Defines the working directory the target starts with.
/R:run style : Defines the window state (1=Normal, 3=Max, 7=Min).
/I:icon,index : Defines the icon and optional index (file.exe or
file.exe,0).
/H:hotkey : Defines the hotkey, a numeric value of the keyboard
shortcut.
/D:description : Defines the description (or comment) for the shortcut.

Notes:
- Any argument that contains spaces must be enclosed in "double quotes".
- If Query is specified (/A:Q), all arguments except /F: are ignored.
- To find the numeric hotkey value, use Explorer to set a hotkey and then
/A:Q
- To prevent an environment variable from being expanded until the shortcut
is launched, use the ^ carat escape character like this: ^%WINDIR^%

Examples:
/f:"%ALLUSERSPROFILE%\Start Menu\Programs\My App.lnk" /a:q
/f:"%USERPROFILE%\Desktop\Notepad.lnk" /a:c /t:^%WINDIR^%\Notepad.exe
/h:846
/f:"%USERPROFILE%\Desktop\Notepad.lnk" /a:e /p:C:\Setup.log /r:3

An argument of /? or -? displays this syntax and returns 1.
A successful completion will return 0.


Copyright 2000-2005 Marty List, www.OptimumX.com

"Jason Gurtz" wrote:

> I was hoping that some kind of 'New-Item -Type "Shortcut"' invocation
> would do, but apparently not.
>
> Is there any way to create shortcuts in PS without using the legacy WSH
> CreateShortcut method?
>
> Specifically, this legacy method does not allow for setting the icon on
> web (.url) shortcuts, even though you can do that through the GUI.
> Maybe WMI has a better way?
>
> ~Jason
>
> --
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Creating shortcut to the Desktop Vista General
Vista Navigation Pane - Copies files rather than creating shortcut? Vista file management
Removing "Shortcut" word after creating a shortcut? Vista file management
creating a shortcut for my desktop Vista mail
Creating a shortcut to a VPN connection Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46