I have NAS server on OMV 6. And users on Win 10. On NAS I have users: student1 and student2(actualy much more) and personal folders for each. Users on Win 10 use CMD:
net use * /del /y
net use \\192.168.1.1 /user:username password
%SystemRoot%\explorer.exe "\\192.168.1.1\"
It's work good, but not really comfortable for users. So I decided to make "User changer" application on WPF. enter image description here I need something like "net use" but programly. Are there any solutions of this?
I tried SMBLibrary, it's works(copy/paste/delete and etc.). But I cann't open shared folders via Explorer. I need just access to shared folders via Windows 10 Explorer. I get code frome here "Login and list shares:"
public string nas_ip = "192.168.1.1";
public string nas_log = "username";
public string nas_pas = "pass";
private void btn_connect_Click(object sender, RoutedEventArgs e)
{
SMB2Client client = new SMB2Client();
bool isConnected = client.Connect(IPAddress.Parse(nas_ip), SMBTransportType.DirectTCPTransport);
if (isConnected)
{
NTStatus status = client.Login(String.Empty, nas_log, nas_pas);
if (status == NTStatus.STATUS_SUCCESS)
{
List<string> shares = client.ListShares(out status);
this.textBox_1.Text = String.Join(Environment.NewLine, shares);\\it shows shared folders list in textbox
Process.Start("explorer.exe", @"\\"+nas_ip+@"\");\\here I try to open explorer with shared folders
}
}
}