C Sharp
Compiling and Running Code
Save the following code in file 'cmdexe.cs'. The FileName and Arguments makes the program run with it's process hidden in background:
class Cmdexec {
static void Main(){
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = " /c echo 'fire' > C:\\Users\\<username>\\Desktop\\cs-file";
process.StartInfo = startInfo;
process.Start();
}
}
2. Compile the code to an executable format (.exe):
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe .\cmdexe.cs
Last updated
Was this helpful?