I'm having a problem with my .exe application that I created to map shared folders as disks.
The user writes his username and password and if they are correct, he maps a checkbox and maps that shared folder This is the code I use:
If checkbox is checked {
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = $@"/C net use z: \\192.168.XXX.XXX\sharedFolder {password} /user:domain.com\{username} /persistent:yes && cmdkey /add:192.168.XXX.XXX\sharedFolder /user:domain.com\{username} /pass:{password}";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
}
Now comes the weird
When I run the program, everything works perfectly, but when I restart, the mapped drives appear like this:
When I want to enter, it asks for a password.
The strange thing is that the credentials of that IP are saved in the windows credential manager
And much more strange is that if I copy the network route in the explorer it enters me without problem, it does not ask me for a password
What am I doing wrong?