 |
Your forum announcement here! |
|
 |

15-08-2007, 19:05
|
|
new member
|
|
Join Date: Aug 2007
Posts: 4
|
|
Visual Studio 2005-Setup program: App Install location and Shortcuts
Have developed a simple Windows application in VS2005, using Visual Basic. It works fine. Problem is related in installing it using a setup program.
The program installs on my (development) machine and also on another machine via the webpage with the install button on it.. A new entry in the Start Menu is created which points to an Application Reference in Documents and Settings/User Name/StartMenu/Programs/Program Name. I cannot find the exe file on my machine (other than the one which was created in developing the application in its project/bin/debug folder) and this is dated before I clicked the install button. Where is the exe?
Also, my main problem which, perhaps is connected with the above, is that I cannot create any shortcuts on the desktop by adding them to the User's Desktop folder in File System Editor.
I have right clicked the Application folder and selected Add Project Output which creates Primary Output file. I then right clicked it to create a shortcut which I dragged to the User's Desktop folder. However, when I install from the webpage, no shortcut appears on the desktop. Have also tried inserting folders containing files in the User's Desktop folder but they still do not appear.
The default location for the Application folder is [ProgramFilesFolder][Manufacturer]\[ProductName] the application is not in this folder.
Have searched high and low for an answer but cannot find one.
Would be most grateful for anyone's help.
|

19-08-2007, 22:33
|
|
Member
|
|
Join Date: Jul 2007
Posts: 44
|
|
Which setup program are you using?
Usually programs are installed in a subdirectory of the c:\Program Files\ directory, for example Skype installs to c:\Program Files\Skype\
|

20-08-2007, 13:17
|
 |
Senior Member
|
|
Join Date: Nov 2005
Location: Norway
Posts: 1,857
|
|
I think he get resolved the issue from microsoft; forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2010785&SiteID=1
|

20-08-2007, 18:50
|
|
Member
|
|
Join Date: Jul 2007
Posts: 44
|
|
Quote:
Originally Posted by paul
I think he get resolved the issue from microsoft; forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2010785&SiteID=1
|
OK Thanks Paul
|

21-08-2007, 15:00
|
|
new member
|
|
Join Date: Aug 2007
Posts: 4
|
|
Hi Stukely and Paul,
Have tried the following coding and it seems to work. Would be most grateful for your comments on it:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
‘Create shortcuts to program and to online database on desktop if they do not exist
CreateShortcuts()
Dim DirInfo As System.IO.DirectoryInfo
‘Creates LIFEnet directory if it does not exist
If Not DirExists("C:\LIFEnet") Then
DirInfo = System.IO.Directory.CreateDirectory("c:\LIFEnet")
End If
‘Creates LIFEnet\Templates directory if it does not exist
If Not DirExists("C:\LIFEnet\Templates") Then
DirInfo = System.IO.Directory.CreateDirectory("C:\LIFEnet\Te mplates")
‘Copies Word Template into directory
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
‘Creates LIFEnet\Documents directory if it does not exist
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
‘Check if directory exists
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, objProgramShortcut, 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
The only thing is that, if the user deletes the shortcuts, they are created again when the program runs. Suppose I could create a text file with, say, an integer value in it (starting with 1). After shortcuts are created, this value is changed to 0 and the program checks this value when it runs. If 1, creates shortcuts, otherwise does nothing.
I am sure there is more elegant way of doing this!
Anyway, would much appreciate you view of the coding.
Regards
Brian
|

31-08-2007, 20:17
|
|
Member
|
|
Join Date: Jul 2007
Posts: 44
|
|
Hi,
Your installer should create the required short cuts for your program.
Personally I don't like too many icons on my desktop, it just clutters it up.
Cheers Stu
|

02-09-2007, 12:00
|
|
new member
|
|
Join Date: Aug 2007
Posts: 4
|
|
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
|

02-09-2007, 13:45
|
|
Member
|
|
Join Date: Jul 2007
Posts: 44
|
|
Hi Brian,
Quote:
Originally Posted by bogorman
May modify it to only create short cuts if the folders do not exist (e.g. when the program is first installed).
|
Yeah that sounds good.
I would also recommend that you use a domain name, instead of a fixed IP, for downloading the template. That way the code will still work if your IP address ever changes.
Also your directories are hard coded to C: drive. It is possible, although unlikely, that the user may not have a C: drive on their computer.
Good luck, Stu
|

02-09-2007, 14:51
|
|
new member
|
|
Join Date: Aug 2007
Posts: 4
|
|
shortcuts, etc
Hi Stu,
Yes, I do intend to eventually use a domain name.
Your point about C: is certainly worth considering. However, the database is for a charity and will only be used by about a dozen people. As far as I know (and this can be established when we go "online") they will all use machines with a C: drive.
Thanks again for all your help. Much appreciated
Brian
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 15:44.
|
|
|