?
Solved

Visual Studio 2013 Publish

Posted on 2016-10-04
13
Medium Priority
?
72 Views
Last Modified: 2016-10-12
I created an app to check a text file on the server and if the file on the client is different it runs an update program.

We have a new server so I published the app to that, when I run setup.exe it puts the shortcut in the start menu but does nor overwrite the original. I end up with 2 shortcuts 'myapp' and 'myapp - 1'.

Is there a way to publish this so it overwrites the original app? (or do I have to uninstall the old one 1st?)
0
Comment
Question by:HKFuey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 9

Expert Comment

by:Karen
ID: 41829017
I am guessing it is not being overwritten because it is being written to a different place.
You do not mention which O/S is on the client.
If you right click the 'myapp' shortcut, choose properties and go to the general tab, then note what the value of Location is. Then do the same to the 'myapp-1" shortcut and see if they are in two different places.
0
 

Author Comment

by:HKFuey
ID: 41829417
Hi Snowberry
I looked at properties, they were both C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\MyFolder.

Uninstalling and reinstalling does fix my problem, it's just a pain.

I'm on Windows 7 and Visual Studio Express 2013. Maybe the Express version has limitations?
0
 
LVL 9

Expert Comment

by:Karen
ID: 41831007
How do you create the setup.exe? Is it via a second project within your Visual studio solution?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:HKFuey
ID: 41831281
Hi Karen,
I am retiring the server I originally published the .exe to, so I just made a minor change in the code and published to a new location.
0
 
LVL 9

Expert Comment

by:Karen
ID: 41832811
No, I need to know where setup.exe comes from. Is it your compiled app?
0
 

Author Comment

by:HKFuey
ID: 41833121
Yes, from the compiled app.
0
 
LVL 9

Expert Comment

by:Karen
ID: 41836297
What do you mean?
Is it your app, or is it a separate setup program for your app?
Do you run setup.exe once, and then it installs yourapp.exe?
0
 

Author Comment

by:HKFuey
ID: 41836465
It is just a few lines of VB that I publish to a network share. This creates 3 files: 'publish.html', 'my program.application' and 'Setup.exe' and a folder called 'Application Files'.

This creates a 'Click Once' shortcut in the Start Menu of the PC: -

C:\Users\username\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu
0
 

Author Comment

by:HKFuey
ID: 41836467
Sorry!
It is C:\Users\User\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\MyCompanyName
0
 
LVL 9

Expert Comment

by:Karen
ID: 41837878
okay then... how do you create the shortcut - what is your line(s) of code?
0
 

Author Comment

by:HKFuey
ID: 41837981
The problem is when I publish to the new server, it creates a second shortcut instead of overwriting the old one when I run setup.exe

I think I'll just have to uninstall the old version before installing the new, which checks for a version number text file on the new server: -

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        On Error GoTo ErrorTrap

        'Create folder
        Dim FOLDER_NAME As String = "C:\Program Files\*************\"
        If (Not System.IO.Directory.Exists(FOLDER_NAME)) Then
            System.IO.Directory.CreateDirectory(FOLDER_NAME)
        End If

        'Create version text file if does not exist
        Dim FILE_NAME As String = "C:\Program Files\************\Text.txt"
        If System.IO.File.Exists(FILE_NAME) = False Then
            Dim fs As IO.FileStream = IO.File.Create(FILE_NAME)
            fs.Close()
            'Write to file
            Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
            objWriter.WriteLine("1")
            objWriter.Close()
        End If

        Dim fileReader As String
        fileReader = My.Computer.FileSystem.ReadAllText("\\new server\VersionsDb\text.txt")
        'MsgBox("1 " & fileReader)

        Dim fileReader2 As String
        fileReader2 = My.Computer.FileSystem.ReadAllText("C:\Program Files\**********\text.txt")
        'MsgBox("2 " & fileReader2)

        If Val(fileReader) = Val(fileReader2) Then 'Launch Access
            System.Diagnostics.Process.Start("C:\Program Files\***************\Access.accdb")
        Else

            'Change local file to match network file
            Dim textFileStream As New IO.FileStream("C:\Program Files\************\text.txt", IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite, IO.FileShare.None)
            Dim myFileWriter As New IO.StreamWriter(textFileStream)
            myFileWriter.WriteLine(fileReader)
            myFileWriter.Close()
            textFileStream.Close()

            MsgBox("Your ****** program is out of date, please run the installer")
            'Open installer, this copies the updated Access program to the client (Created by an app 'Install Creator Pro')
            System.Diagnostics.Process.Start("\\new server\**************\myAccessUpdaterSetup.exe")
            End

        End If

        End

'If all fails just open Access
ErrorTrap:
        MsgBox(Err.Description)
        System.Diagnostics.Process.Start("C:\Program Files\************\Access.accdb")
        End

    End Sub
End Class

Open in new window

0
 
LVL 9

Accepted Solution

by:
Karen earned 2000 total points
ID: 41839330
The problem is not in your vb code - the problem is in myAccessUpdaterSetup.exe.
I do not know about 'Install Creator Pro' so I cannot help exactly, but there must be some way to configure it to ensure the start menu entry gets overwritten.
Or you can delete the start menu entry before you run myAccessUpdaterSetup.exe, doing something like

           MsgBox("Your ****** program is out of date, please run the installer")

           Dim ShortcutPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) & "\Programs\MyCompanyName\myapp.lnk"
           If My.Computer.FileSystem.FileExists(ShortcutPath) Then
               My.Computer.FileSystem.DeleteFile(ShortcutPath)
           End If
            'Open installer, this copies the updated Access program to the client (Created by an app 'Install Creator Pro')
            System.Diagnostics.Process.Start("\\new server\**************\myAccessUpdaterSetup.exe")

Open in new window

0
 

Author Closing Comment

by:HKFuey
ID: 41839593
That looks a really good workaround. I will try it when I get time.
Thanks!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question