abinaya r

abinaya r

  • NA
  • 10
  • 37.5k

run net use command from c# console

Nov 15 2013 12:45 AM
hello all .. 

I want to use the "net use" command from the c# console application.. 

I tried the following but it says wrong user name or bad password..  but the same is working when i execute thru cmd prompt. 
please help me..

Process.Start("cmd.exe", "/C" + "net use \\<<myip>> <<mypassword>> /USER:<<myusername>>");

Process.Start("cmd.exe","/C net use \\<<myip>> <<mypassword>> /USER:<<myusername>>");

Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C net use \\<<myip>> <<mypassword>> /USER:<<myusername>>";
process.StartInfo = startInfo;
Process.Start(startInfo);

Can anyone please tell me where I have gone wrong..

Answers (8)