Creating a Shortcut might be a difficult task in any scripting language in Windows. Not sure how difficult or simple is there in Unix.
Let's take a look on the simple few lines which accomplish this task -
clear $wsc = New-Object -ComObject ("Wscript.Shell")$sc=Join-Path -Path "d:\test" -childpath "Notepad.lnk" $slink=$wsc.CreateShortcut($sc)$slink.TargetPath = "C:\windows\notepad.exe" $slink.WindowStyle = 0 $slink.Hotkey = "CTRL+SHIFT+F" $slink.IconLocation = "notepad.exe, 0" $slink.WorkingDirectory = "d:\Test" $slink.Save()
Since this uses Wscript.Shell which is VBScript shell, there are some Windows version where you do not see desired output. Please let me know..
Enjoy!
No comments:
Post a Comment