.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!



Home >> Forum >> VB.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to create shortcut icon in vb.net

Posted By: Mahesh     Posted Date: June 21, 2012    Points:5   Category :VB.Net
How to create shortcut icon for an exe through code in vb.net

Responses
Author: Mahesh          Company URL: http://www.dotnetspark.com           
Posted Date: June 21, 2012     Points: 20   

oWScriptShell = CreateObject("WScript.Shell")

'Read desktop path using WshSpecialFolders object
sStartMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu)

If Not String.IsNullOrEmpty(oTaskStruct.StartMenuDirectoryPath) Then
sFolders = MenuDirectoryPath.Split("\")
sFolderPath = sStartMenuPath
For Each sFolder As String In sFolders
sFolderPath = Path.Combine(sFolderPath, sFolder)

If Not Directory.Exists(sFolderPath) Then
Directory.CreateDirectory(sFolderPath)
End If
Next
End If

' Create a shortcut object on the desktop
oShortcut = oWScriptShell.CreateShortcut(Path.Combine(Path.Combine(sStartMenuPath, MenuDirectoryPath), LinkName & ".lnk"))

' Set shortcut object properties and save it
oShortcut.TargetPath = oWScriptShell.ExpandEnvironmentStrings(Path.Combine(ShortcutIconExePath, ShortcutIconExeName))

oShortcut.WorkingDirectory = oWScriptShell.ExpandEnvironmentStrings(ShortcutIconExePath)
oShortcut.WindowStyle = 4

'Use this next line to assign a icon other then the default icon for the exe
'MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("path to a file with an embeded icon", icon index number)
'Save the shortcut
oShortcut.Save()



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend