8
Answers

run net use command from c# console

abinaya r

abinaya r

11y
13k
1
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)