darcher23
asked on
Create an application shortcut using VB.NET code
Hi Experts,
I have code using the Windows Scripting Host Object, to successfully create a desktop shortcut. However, my problem is populating this shortcut with the correct startup parameters.
The string required in the TARGET field has 2 parameters - an integer, and a code. I've found that when I create the shortcut, it encapsulates the entire File Path Integer Code in quotes, where as I need either each component in quotes, or no quotes at all (best).
eg. C:\Users\fredsmith\Project s\HelloWor ls\bin\Deb ug\HellowW orld.exe 3 MAP
Any suggestions out there?
Cheers,
David.
I have code using the Windows Scripting Host Object, to successfully create a desktop shortcut. However, my problem is populating this shortcut with the correct startup parameters.
The string required in the TARGET field has 2 parameters - an integer, and a code. I've found that when I create the shortcut, it encapsulates the entire File Path Integer Code in quotes, where as I need either each component in quotes, or no quotes at all (best).
eg. C:\Users\fredsmith\Project
Any suggestions out there?
Cheers,
David.
Public Function CreateShortCut(ByVal strName As String, ByVal strTargetDirectory As String, ByVal strTargetPath As String, ByVal strWorkingDir As String, ByVal strIconFile As String, ByVal strBatch As String) As clsResult
Dim wshShell As New WshShell
Dim desktop As String = My.Computer.FileSystem.SpecialDirectories.Desktop
'Dim desktop As String = wshShell.SpecialFolders.Item("Desktop").ToString()
Dim shortcut As IWshShortcut = CType(wshShell.CreateShortcut(desktop & "\" & strName.ToString & ".lnk"), IWshShortcut)
With shortcut
.TargetPath = strTargetPath.Replace(Chr(34), String.Empty)
.WorkingDirectory = strWorkingDir
.IconLocation = strIconFile
.WindowStyle = 1
.Description = "Ripteq Automation Task for Batch: " & strBatch
.Save()
End With
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cool :)
ASKER