1 year ago

#238819

test-img

Rick

Use Process.Start to open explorer.exe window to UNC path that requires login

I would like to open a Windows Explorer window to a UNC path that requires a login outside of my network using System.Diagnostics.Process.Start. I do not want or need to pass credentials to actually access the folder, I just want to open an explorer window to that path and have it pop up its own login prompt for the user. When I try, it opens to the user's Documents folder on the local machine instead, and no exceptions are thrown. When I run it within the domain where the UNC folder is located, it opens the proper path. I can access the path within explorer manually from outside the domain (after the login prompt).

I'm calling this from a thread, so I'm using Invoke.

public void OpenExplorer(string path)
{
    //string path = string.Format("\"{0}\"", path); // tried wrapping path in quotes
    
    var openExplorer = new System.Diagnostics.ProcessStartInfo
    {
        FileName = "explorer.exe",
        Arguments = "/open " + path,
        // Arguments = "/open, " + path,    // tried with and without comma
        // Arguments = path,                // tried without /open
        UseShellExecute = true              // tried with and without UseShellExecute
    };

    this.Invoke(new Action(() => { System.Diagnostics.Process.Start(openExplorer); }));
}

How can I get explorer to open the correct path and prompt with a login as it does when you enter the path manually?

c#

.net

unc

windows-explorer

process.start

0 Answers

Your Answer

Accepted video resources