什么会导致 Windows InstallDate 更改? [英] What can cause Windows InstallDate to change?

查看:40
本文介绍了什么会导致 Windows InstallDate 更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何原因会导致 Windows 安装日期发生变化 - 特别是 Win32_OperatingSystem 类中的 InstallDate.我们在 C# 中使用 ManagementObjectSearcher 来获取各种系统信息以用于许可目的,并且在某些计算机上,Windows 安装日期无缘无故地更改了.

I was wondering if there is anything that can cause the Windows Install Date to change - specifically InstallDate from the Win32_OperatingSystem class. We are using the ManagementObjectSearcher in C# to get various system information for licencing purposes, and on some computers, the windows install date has changed for no apparent reason.

我一直试图找出它从哪里获取安装日期信息的确切位置,以便确定安装新的服务包或 .net 版本是否可能导致这种情况,但无济于事.

I have been trying to find out exactly where it gets the information for the install date from in order to work out if installing a new service pack or version of .net might cause this, but to no avail.

不幸的是,我们甚至无法看到它的变化,因为信息是散列的(好吧,我们可能会看到它变成了什么,但我们将不得不再次打扰客户).

Unfortunately we can't even see what it has changed from and to because the information is hashed (well, we might get to see what it has changed to, but we would have to bother the customer again).

我想可能发生的另一件事是日期时间从一种格式到另一种格式的转换可能由于某种原因而发生了变化,但如果可能的话,我无法理解它.这就是我们正在做的:

I guess the other thing that might have happened is that the conversion of the date-time from one format to another might have changed for some reason, but I can't get my head around it to work out if it might. This is what we are doing:

ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
foreach (ManagementObject wmi_Windows in searcher.Get())
{                   
  try
  {
    s = wmi_Windows["InstallDate"].ToString();
    DateTime dc = ToDateTime(s);
    WindowsInfo.InstallDate = dc.AddTicks(-TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Ticks).ToLocalTime().ToString();
     break;
   }
   catch (Exception ex)
   {
     //stuff here
   }
 }

推荐答案

Win32_OperatingSystem WMI 类从 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion 中检索\InstallDate 键,此 Windows 注册表值存储为自 1970 年 1 月 1 日以来的秒数.如果您修改该 Windows 注册表值,然后再次运行 WMI 查询,您将修改该值.

The value returned by the property InstallDate of the Win32_OperatingSystem WMI class is retrieved from the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate Key, this windows registry value is stored as the number of seconds since January 1, 1970. if you modify that windows registry value and then run the WMI Query again you will get the value modified.

这篇关于什么会导致 Windows InstallDate 更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆