Command prompt must be invisible ( run in background ) %26amp; I want to run a command in it Invicibley ("copy c:\text.txt a:\ ").
I use ' System.diognatics.process.start("cmd.exe... ' It execute the process but i cannot make it invisible.
Also i need to change the path on the command prompt with coding.
can i use a batch file also to this?
please help me with c#.net code.
How can i start a process("cmd.exe") using c#.NET?
public static int executeCommand(string cmd, int millsecTimeOut)
{
System.Diagnostics.ProcessStartInfo processStartInfo =
new System.Diagnostics.ProcessStartInfo("CMD... "/C "+cmd);
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
System.Diagnostics.Process process =
System.Diagnostics.Process.Start(proce...
process.WaitForExit(millsecTimeOut); //wait for 20 sec
int exitCode = process.ExitCode;
process.Close();
return exitCode;
}
Reply:If you want to manipulate a file, i don't know why you want to use cmd (command dos). Try the .net IO. Here's a simple example:
System.IO.File.Copy ("c:/file.txt", "c:/file1.txt");
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment