Monday 14 February 2011

New-Shortcut.ps1

  1. <# 
  2. .SYNOPSIS 
  3.    This script creates a shortcut to Notepad on the Desktop 
  4. .DESCRIPTION 
  5.    This script creates a Wscript.shell item, then creates  
  6.    a shortcut on the desktop to Notepad.exe. 
  7. .NOTES 
  8.     File Name  : New-Shortcut.ps1 
  9.     Author     : Thomas Lee - tfl@psp.co.uk 
  10.     Requires   : PowerShell Version 2.0 
  11. .LINKS 
  12.     This post is a re-implementation of an MSDN Script 
  13.         http://msdn.microsoft.com/en-us/library/0ea7b5xe%28VS.85%29.aspx 
  14.     Posted to Powershell Scripts Blog 
  15.         HTTP://Pshscripts.blogspot.com 
  16. .EXAMPLE 
  17.    Left as an exercise for the reader 
  18. #> 
  19.  
  20. # create wscript object 
  21. $WshShell = New-Object -com Wscript.Shell 
  22.  
  23. #Get Desktop location 
  24. $Desktop  = $WshShell.SpecialFolders.item("Desktop"
  25.  
  26. # create a new shortcut 
  27. $ShellLink                  = $WshShell.CreateShortcut($Desktop + "\Shortcut Script.lnk"
  28. $ShellLink.TargetPath       = $WScript.ScriptFullName 
  29. $ShellLink.WindowStyle      = 1 
  30. $ShellLink.Hotkey           = "CTRL+SHIFT+F" 
  31. $ShellLink.IconLocation     = "notepad.exe, 0" 
  32. $ShellLink.Description      = "Shortcut Script" 
  33. $ShellLink.WorkingDirectory = $Desktop 
  34.  
  35. #Save the link to the desktop 
  36. $ShellLink.Save() 

2 comments:

skatterbrainz said...

It seems to me that the vast majority of PS examples on the web today are adaptations of VBscript or WMI. Why aren't there more examples of what PS can do that other script languages cannot do?

MicrosoftGirl said...

I work for Microsoft and I'm hiring for both PowerShell Dev's and PowerShell SDET's. I was wondering if you may know anyone interested in working at Microsoft in this capacity. I know that you have a great following when it comes to PowerShell. Any help or advice you can give would be greatly appreciated.

Please feel free to contact me at anytime or share my information. My email address is v-saraec@microsoft.com