I have a textbox called txtMinuto
and a button called btnApagar
. I want to use the command SHUTDOWN -s -t
that is used to turn off the PC at a predetermined time but when I run my line of code to turn off the PC according to the time I entered in my textbox.
My line of code is not running correctly:
private void btnApagar_Click(object sender, EventArgs e)
{
int tiempo;
int _result=0;
String _minuto = txtMinuto.Text;
tiempo = Convert.ToInt32(txtMinuto.Text);
if (_minuto != "")
{
_result = (tiempo * 60);
}
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe","SHUTDOWN -s -t "+ _result);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
}