vb.net application cannot access my.settings when started by another program

51 views Asked by At

I wrote an application that stores some settings in My.Settings in order to be used within the Application_StartUp event if e.Args has some specific data.

My problem is that the software should run automatically when started by another software but it seems that it cannot access My.Settings if it is started like that.

I guess that this is some Windows Security Police ...

Does anyone have an idea how I can work around this problem?

PS: I already tried to save the information in an XML file and load it while start up. But this also did not seem to work ...

@nbk There is not much to show:

Private Sub Application_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
    Dim Folder As String = My.Settings.BaseDirectory & "\Results\"
    
    If (My.Settings.SubDirectory.Length > 0) Then
        Folder &= My.Settings.SubDirectory & "\"
    End If
End Sub

If I just run my application Folder looks like "C:\BaseFolder\Results\SubFolder" but if I try to run it via another software (which I did not write) it just looks like "\Results"


I wrote this console app:

Sub Main()
    Try
        Dim args = My.Application.CommandLineArgs
        If args.Count = 0 Then Throw New Exception("No Result given")

        Dim executable As String = "C:\Path\Executable.exe"
        If Not File.Exists(executable) Then Throw New Exception("Executable not found")

        Dim path = IO.Path.GetDirectoryName(executable)
        If Not Directory.Exists(path) Then Throw New Exception("Working directory not found")

        Dim result As String = String.Join(" ", args)

        Dim info As New ProcessStartInfo(executable, Chr(34) & result & Chr(34)) With {
            .UseShellExecute = True,
            .WorkingDirectory = path
        }
        Dim p = Process.Start(info)
        p.WaitForExit()
    Catch ex As Exception
        Console.WriteLine(ex.Message)
    End Try
End Sub

If I run it separately it works, but if I try to run it via the third party software it does not work ...

0

There are 0 answers