Hi Stu,
Decided to create the shortcuts and folders in the program itself:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Me.Text = "LIFEnet Mailing Program. Version " & My.Application.Deployment.CurrentVersion.ToString
Catch inv As System.Deployment.Application.InvalidDeploymentExc eption
Me.Text = "LIFEnet Mailing Program. Version " & My.Application.Info.Version.ToString
End Try
CreateShortcuts()
Dim DirInfo As System.IO.DirectoryInfo
If Not DirExists("C:\LIFEnet") Then
DirInfo = System.IO.Directory.CreateDirectory("c:\LIFEnet")
End If
If Not DirExists("C:\LIFEnet\Templates") Then
DirInfo = System.IO.Directory.CreateDirectory("C:\LIFEnet\Te mplates")
Try
My.Computer.Network.DownloadFile("http://63.134.211.113/LIFEnetMail/LIFEnet Letter Template.dot", "C:\LIFEnet\Templates\LIFEnet Letter Template.dot", "", "", False, 10000, True)
Catch ex As Exception
MessageBox.Show("Unable to copy Letter Template" & vbCrLf & ex.Message)
End Try
End If
If Not DirExists("C:\LIFEnet\Documents") Then
DirInfo = System.IO.Directory.CreateDirectory("c:\LIFEnet\Do cuments")
End If
End Sub
Private Function DirExists(ByVal DName As String) As Boolean
Dim sDummy As String
Dim RightStr As String
On Error Resume Next
RightStr = Strings.Right(DName, 1)
If RightStr <> "\" Then DName = DName & "\"
sDummy = Dir$(DName & "*.*", vbDirectory)
DirExists = Not (sDummy = "")
End Function
Public Sub CreateShortcuts()
Dim objShell, strProgramsFolder, strDesktopFolder, objURLShortcut, objFSO
objShell = CreateObject("WScript.Shell")
objFSO = CreateObject("Scripting.FileSystemObject")
strDesktopFolder = objShell.SpecialFolders("Desktop")
strProgramsFolder = objShell.SpecialFolders("Programs")
'Create shortcut to program
If Not objFSO.FileExists(strDesktopFolder & "\LIFEnetMail Program.appref-ms") Then
Dim ProgramPath = strProgramsFolder & "\LIFEnet Software\LIFEnetMail Program.appref-ms"
Dim DesktopPath = strDesktopFolder & "\LIFEnetMail Program.appref-ms"
Try
System.IO.File.Copy(ProgramPath, DesktopPath, True)
Catch e As Exception
Throw e
End Try
End If
'Create shortcut to online database
If Not objFSO.FileExists(strDesktopFolder & "\LIFEnet Online Database.url") Then
objURLShortcut = objShell.CreateShortcut(strDesktopFolder & "\LIFEnet Online Database.url")
objURLShortcut.TargetPath = "http://63.134.211.113/login.asp"
objURLShortcut.Save()
End If
objShell = Nothing
objFSO = Nothing
End Sub
Realise that many people dislike shortcuts on the desktop but thought I should initially create them and then users can delete them if they wish. Trouble is that the present coding will recreate them with every update. May modifiy it to only create shortcuts if the folders do not exist (e.g. when the program is first installed). Thanks again for all your help.
Regards, Brian
|