简体   繁体   English

确定Windows计算机何时已完全启动并开始响应

[英]Determine When Windows Computer has fully booted and becomes responsive

I know this question has been asked before in different situations. 我知道以前在不同情况下都曾问过这个问题。

I want to write a C# program that pops up a message when a Windows Vista or Windows 7 computer has fully booted up. 我想编写一个C#程序,当Windows Vista或Windows 7计算机完全启动时弹出一个消息。 (Everything is loaded, the hard drive has settled and the computer is responsive) (所有内容均已加载,硬盘驱动器已安装,并且计算机已响应)

Currently I am using a timer. 目前,我正在使用计时器。 I was wondering if there was maybe a way to determine when all the services have started or something like that? 我想知道是否有办法确定何时启动所有服务或类似的服务?

Edit: 编辑:

I have something that seems to work fairly well: 我有一些似乎工作得很好的东西:

using System.Diagnostics;
public partial class Form1 : Form
{
    private PerformanceCounter cpuCounter;
    private PerformanceCounter diskCounter;
    private int seconds;
    private int lowUsage;

    private const String timeMsg = "Waiting for Boot: ";
    private const String cpuMsg = "CPU: ";
    private const String diskMsg = "Disk: ";

    public Form1()
    {
        InitializeComponent();

        cpuCounter = new PerformanceCounter();
        cpuCounter.CategoryName = "Processor";
        cpuCounter.CounterName = "% Processor Time";
        cpuCounter.InstanceName = "_Total";

        diskCounter = new PerformanceCounter();
        diskCounter.CategoryName = "PhysicalDisk";
        diskCounter.CounterName = "% Disk Time";
        diskCounter.InstanceName = "_Total";

        seconds = 0;
        lowUsage = 0;

        Timer timer = new Timer();
        timer.Interval = 1000;
        timer.Tick += tick;
        timer.Start();

        timeLabel.Text = timeMsg + seconds;
        cpuLabel.Text = cpuMsg + "100%";
        diskLabel.Text = diskMsg + "100%";

        StartPosition = FormStartPosition.CenterScreen;

    }

    private void tick(Object o, EventArgs e)
    {
        seconds++;
        int cpu = (int)cpuCounter.NextValue();
        int disk = (int)diskCounter.NextValue();

        if (cpu < 5 && disk < 5) lowUsage++;
        else lowUsage = 0;

        if (lowUsage >= 5 && seconds > 35) Application.Exit();

        timeLabel.Text = timeMsg + seconds;
        cpuLabel.Text = cpuMsg + cpu + "%";
        diskLabel.Text = diskMsg + disk + "%"; 
    }
}

You could try for resting CPU usage, hard drive usage, or perhaps a combination of both. 您可以尝试降低CPU使用率,硬盘驱动器使用率,或者两者结合。 My computer is 1 to 4% usage if nothing is going on. 如果没有任何反应,我的计算机的使用率为1-4%。 During boot it's much higher. 在启动过程中,它要高得多。 Might have to do some kind of math to find trends of spikes and stability. 可能必须做某种数学运算才能找到峰值和稳定性的趋势。 That's how I'd go about it, anyway. 无论如何,这就是我要做的。 I don't know about the services option. 我不知道服务选项。 I kinda doubt there's a way to ask each one if they're done loading and doing their thing even if you could get a list of them. 我有点怀疑是否有一种方法可以询问每个人,即使您可以获得它们的列表,它们是否都已完成加载并完成了他们的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 确定远程计算机的最佳方法已启动并正在运行 - Best way of determining a remote computer has booted and running C#:以编程方式检测 Windows Server 已启动 - C#: Programmatically Detect Windows Server Has Booted 检测用户何时完全登录计算机 - Detect when a user is fully logged on computer 如何确定计算机是否有wifi适配器? - How to determine if the computer has a wifi adapter? 确定AD中的计算机是否有用户登录 - Determine if a computer in AD has a user logged in 如何确定Windows域中的计算机是否处于“活动”状态 - How to determine if a computer in my Windows Domain is “active” 一个程序在我的计算机上工作正常,但是当我使用荷兰语Windows在另一个程序上发送该程序时,DateTimePicker出现了问题 - A program worked fine on my computer but when I sent it on another one with a Dutch Windows it has problems with the DateTimePicker Gui 反应迟钝 - Gui becomes less responsive 确定在WPF中使用WebBrowser视图时页面何时完成加载(Windows.Controls.WebBrowser) - Determine when a page has finished loading when using WebBrowser view in WPF (Windows.Controls.WebBrowser) 如何确定用户控件何时完全加载并显示? - How to determine when the user control is fully loaded and shown?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM