Genel Nasıl Yapılır

C# İle Örnekler #52

c

C# Bilgisayarı Kapatma ( Zaman Ayarlı )

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;//Ekle
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace bilgisayar_kapat
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = "C:\\Windows\\system32\\shutdown.exe";
            psi.Arguments = "-f -s -t 0";
            Process.Start(psi);
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Enabled = false;
            textBox2.Enabled = false;
            textBox3.Enabled = false;
            timer1.Start();
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
   
            System.Diagnostics.Process.Start("shutdown", "-f -s");
   
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            string saat, dakika, saniye;
            saat = textBox1.Text;
            dakika = textBox2.Text;
            saniye = textBox3.Text;
 
 
            if ((Convert.ToString(DateTime.Now.Hour)) == saat && (Convert.ToString(DateTime.Now.Minute) == dakika) && (Convert.ToString(DateTime.Now.Second)) == saniye)
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName = "C:\\Windows\\system32\\shutdown.exe";
                psi.Arguments = "-f -s -t 0";
                Process.Start(psi);
            }
        }
    }
}

 

Yazar Hakkında

Hız Hosting

Yorum Yap