System.Diagnostics.ProcessStartInfo to start a session

E

Eranga

I have a windows application in C# which has the following method
public void InitiateSession(string server,string userName, string passWd
)
{
//To start the command
System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo();
psi.FileName = @"C:\WINDOWS\system32\cmd.exe"; // Path for the cmd
prompt
psi.Arguments = @"c\ net use \\servername\IPC$ /USER:domain\user
password"; // Arguments for the command prompt
psi.WindowStyle =System.Diagnostics.ProcessWindowStyle.Hidden; //
Hide the window
System.Diagnostics.Process p =
System.Diagnostics.Process.Start(psi);//Run
}


but this does not initiate the session. can any one please help me.
 
W

Willy Denoyette [MVP]

Eranga said:
I have a windows application in C# which has the following method
public void InitiateSession(string server,string userName, string passWd
)
{
//To start the command
System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo();
psi.FileName = @"C:\WINDOWS\system32\cmd.exe"; // Path for the cmd
prompt
psi.Arguments = @"c\ net use \\servername\IPC$ /USER:domain\user
password"; // Arguments for the command prompt
psi.WindowStyle =System.Diagnostics.ProcessWindowStyle.Hidden; //
Hide the window
System.Diagnostics.Process p =
System.Diagnostics.Process.Start(psi);//Run
}
@"/c net use....
Note the /c not \c

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top