Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoupdater process spawning error arguments #2891

mnaiman opened this issue Nov 11, 2017 · 3 comments


Copy link

commented Nov 11, 2017


I was investigating an issue why after update TrayIcon was spawning hosted server even when nohosted was specified.
I found this issue, which is more broad.

var args = Environment.CommandLine;

            var args = Environment.CommandLine;
            var app = Environment.GetCommandLineArgs().First();
            args = args.Substring(app.Length);

            if (!Path.IsPathRooted(app))
                app = Path.Combine(InstalledBaseDir, app);

            var executable = Path.GetFileName(app);

            while (true)
                var best = GetBestUpdateVersion(true);
                var folder = best.Key;

                var pi = new System.Diagnostics.ProcessStartInfo(Path.Combine(folder, executable), args)
                    CreateNoWindow = true,
                    UseShellExecute = false,
                    RedirectStandardError = true,
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                    ErrorDialog = false,                    

These are debug variable content during my debug session.

Environment.CommandLine = "D:\Projects\Duplicati\Duplicati\GUI\Duplicati.GUI.TrayIcon\bin\Debug\Duplicati.GUI.TrayIcon.exe" --no-hosted-server --read-config-from-db --server-datafolder="D:\dup\data" --accept-any-ssl-certificate

var app = D:\Projects\Duplicati\Duplicati\GUI\Duplicati.GUI.TrayIcon\bin\Debug\Duplicati.GUI.TrayIcon.exe

args after substring args = e" --no-hosted-server --read-config-from-db --server-datafolder="D:\kerbdup\data" --accept-any-ssl-certificate

Issue is clearly there, that path in commandline is quoted in double quotes, but Environment.GetCommandLineArgs().First() returns result without quotes.

Than substring returns wrong portion of string, and spawn process starts with incorrect arguments and ignore them.


This comment has been minimized.

Copy link
Contributor Author

commented Nov 11, 2017

Found that double quote stripping happens even in arguments:
so -server-datafolder="D:\dup\data" is converted to -server-datafolder=D:\dup\data

There is one reference to this "bug"


This comment has been minimized.

Copy link
Contributor Author

commented Nov 11, 2017

Hope that help for fixing, my dev machine is broken. :(


This comment has been minimized.

Copy link

commented Nov 21, 2017

The link has a mistake, the stripping happens from the commandline, not C#.
You can try the same with a batch script and see the results.

I can see the problem though... the Environment.CommandLine property is actually constructed, and I was assuming that it was the GetCommandLineArgs property that was parsed.

@kenkendk kenkendk closed this in b42ab42 Nov 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.