yokzu

yokzu

  • NA
  • 306
  • 0

Logging remote server with "net use" command

Sep 29 2011 4:48 AM
hello,
I want to log into a remote server and create a text file on there. When I run these command below into "cmd.exe" and then I use to login to server from my computer, it is successfull,

--------------------
net use \\192.168.1.1 pass.123 /user:admin
--------------------

After I run this command from "cmd.exe", I am able to login to server from windows' "run" menu."\\192.168.1.1".   I mean this code makes available to log into this server.

But I want to run these command from my program but I couldnt be able to it. My all codes are below but it isnt seems to works. Because I am not able to log into server manually after I run these codes;

-------------------
  string parametre1 = "/C net use \\192.168.1.1 pass.123 /user:admin";
  Process islem = new Process();
  islem.StartInfo.FileName = "C:\\Windows\\System32\\cmd.exe";
  islem.StartInfo.Arguments = parametre1;
  islem.StartInfo.RedirectStandardOutput = true;
  islem.StartInfo.UseShellExecute = false;
  islem.Start();
  string output = islem.StandardOutput.ReadToEnd();
  islem.WaitForExit();
  textBox2.Text += output;
-------------------

How can I do that?

I hope I can explain myself. If there is questions in your mind, please ask me.

Answers (2)