473,561 Members | 3,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the install date of OS?

yxq
Hello,

How to get the install date of Operation System(Windows XP) using vb.net?

Thank you
Nov 21 '05 #1
6 12542
"yxq" <ga***@163.ne t> skrev i en meddelelse
news:Of******** ******@TK2MSFTN GP10.phx.gbl...
How to get the install date of Operation System(Windows XP) using vb.net?


Use WMI to query the Win32_Operating System for the InstallDate attribute.

/Jens

--
Jens Christian Mikkelsen
http://www.jcmikkelsen.dk
Nov 21 '05 #2
HKEY LOCAL MACHINE/SOFTWARE/MICROSOFT/WINDOWS NT/CURRENT VERSION/Install
Date

In the registry

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Jens Christian Mikkelsen" <je*********@jc mikkelsenNoSpam Please.dk> wrote in
message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
"yxq" <ga***@163.ne t> skrev i en meddelelse
news:Of******** ******@TK2MSFTN GP10.phx.gbl...
How to get the install date of Operation System(Windows XP) using
vb.net?
Use WMI to query the Win32_Operating System for the InstallDate attribute.

/Jens

--
Jens Christian Mikkelsen
http://www.jcmikkelsen.dk

Nov 21 '05 #3

"Jens Christian Mikkelsen" <je*********@jc mikkelsenNoSpam Please.dk> skrev i
en meddelelse news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
"yxq" <ga***@163.ne t> skrev i en meddelelse
news:Of******** ******@TK2MSFTN GP10.phx.gbl...
How to get the install date of Operation System(Windows XP) using
vb.net?
Use WMI to query the Win32_Operating System for the InstallDate attribute.


Here is actual VB.NET code to do what I described above:

Dim dtmInstallDate As DateTime
Dim oSearcher As New ManagementObjec tSearcher("SELE CT * FROM
Win32_Operating System")
For Each oMgmtObj As ManagementObjec t In oSearcher.Get
dtmInstallDate =
ManagementDateT imeConverter.To DateTime(CStr(o MgmtObj("Instal lDate")))
Next
/Jens

--
Jens Christian Mikkelsen
http://www.jcmikkelsen.dk
Nov 21 '05 #4
yxq
Thank you very much!

But my VB.Net is version 2002, the ManagementDateT imeConverter will be
supported!
How to convert the CStr(oMgmtObj(" InstallDate"))? thank you
"Jens Christian Mikkelsen" <je*********@jc mikkelsenNoSpam Please.dk> дÈëÓʼþ
news:eY******** ******@TK2MSFTN GP11.phx.gbl...

"Jens Christian Mikkelsen" <je*********@jc mikkelsenNoSpam Please.dk> skrev i en meddelelse news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
"yxq" <ga***@163.ne t> skrev i en meddelelse
news:Of******** ******@TK2MSFTN GP10.phx.gbl...
How to get the install date of Operation System(Windows XP) using
vb.net?

Use WMI to query the Win32_Operating System for the InstallDate

attribute.
Here is actual VB.NET code to do what I described above:

Dim dtmInstallDate As DateTime
Dim oSearcher As New ManagementObjec tSearcher("SELE CT * FROM
Win32_Operating System")
For Each oMgmtObj As ManagementObjec t In oSearcher.Get
dtmInstallDate =
ManagementDateT imeConverter.To DateTime(CStr(o MgmtObj("Instal lDate")))
Next
/Jens

--
Jens Christian Mikkelsen
http://www.jcmikkelsen.dk

Nov 21 '05 #5
"yxq" <ga***@163.ne t> skrev i en meddelelse
news:uG******** ******@TK2MSFTN GP09.phx.gbl...
Thank you very much!

But my VB.Net is version 2002, the ManagementDateT imeConverter will be
supported!
How to convert the CStr(oMgmtObj(" InstallDate"))? thank you


Oops, I didn't know it wasn't supported in 1.0. The format is WMI specific,
and does not lend itself to direct parsing by .NET. (Which is probably why
MS introduced the converter class.) See the following link for at
description of the format:

http://msdn.microsoft.com/library/en...ime_format.asp

If all you want is the date, you can extract the date part like this:

dtm = DateTime.ParseE xact(s.Substrin g(0, 8), "yyyyMMdd",
Globalization.C ultureInfo.Inva riantCulture)

(Assuming 's' is a String holding the WMI date from the management object.)
Getting the time of day right requires a bit more arithmetic, as the UTC
offset is specified in minutes.

/Jens
--
Jens Christian Mikkelsen
http://www.jcmikkelsen.dk
Nov 21 '05 #6
yxq
Thank you

"Jens Christian Mikkelsen" <je*********@jc mikkelsenNoSpam Please.dk> дÈëÓʼþ
news:O0******** *****@tk2msftng p13.phx.gbl...
"yxq" <ga***@163.ne t> skrev i en meddelelse
news:uG******** ******@TK2MSFTN GP09.phx.gbl...
Thank you very much!

But my VB.Net is version 2002, the ManagementDateT imeConverter will be
supported!
How to convert the CStr(oMgmtObj(" InstallDate"))? thank you
Oops, I didn't know it wasn't supported in 1.0. The format is WMI

specific, and does not lend itself to direct parsing by .NET. (Which is probably why
MS introduced the converter class.) See the following link for at
description of the format:

http://msdn.microsoft.com/library/en...ime_format.asp
If all you want is the date, you can extract the date part like this:

dtm = DateTime.ParseE xact(s.Substrin g(0, 8), "yyyyMMdd",
Globalization.C ultureInfo.Inva riantCulture)

(Assuming 's' is a String holding the WMI date from the management object.) Getting the time of day right requires a bit more arithmetic, as the UTC
offset is specified in minutes.

/Jens
--
Jens Christian Mikkelsen
http://www.jcmikkelsen.dk

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2635
by: Chris Gardner | last post by:
I've tried to install the .Net SDK 1.1 to write C# programs. I downloaded and installed both the framework and the sdk per Microsoft's instructions. However, the installation does not seem to be complete. I cannot find csc.exe. Perhaps I'm not downloading the proper files. What am I doing wrong?
0
6422
by: blupp | last post by:
Hi, I am trying to install the package, but get the following error: cpan> install Date::Manip Running install for module Date::Manip Running make for S/SB/SBECK/DateManip-5.42a.tar.gz LWP not available Fetching with Net::FTP: ftp://ftp.perl.org/pub/CPAN/authors/id/S/SB/SBECK/DateManip-5.42a.tar.gz
12
1641
by: Etienne | last post by:
Hi, I'm writing an activation system for a software, which allows a 15 days grace period. Now the question is... how can I store the date? It has to be kept even if the software is reinstalled, and it must not be too easy to find/delete. I could write a hidden file somewhere in the system or hide it in the registry, but if it is a limited XP...
1
2846
by: Brian | last post by:
I have a C# application that has an install and registration process. I need to create a robust 30day trial that can be register later. I have most of the work done, but I want to know the best way to store the date the product was installed, and then to retrieve this.
3
1434
by: Ruslan Shlain | last post by:
Hello Everyone. I have small problem.I wrote a win service and i need to insatll in on the separate machine. I installed it just file on the development machine but when it comes to putting it on the server just does not work. I use command prompt in both cases and i use installutil do do everything. The only difference is on my bev machine...
7
4988
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying. I created the websetup and built the MSI, have the bundled version. Copied to webserver and ran Websetup.msi. Said I had to remove old version,...
8
1862
by: rbt | last post by:
On windows xp, is there an easy way to extract the information that Python added to the registry as it was installed?
3
9278
by: Anthony Smith | last post by:
I always get this message. No matter what package $ pear install Date PHP Warning: Module 'oci8' already loaded in Unknown on line 0 No releases available for package "pear.php.net/Date" Cannot initialize 'Date', invalid or missing package file Package "Date" is not valid install failed
4
1366
by: =?Utf-8?B?S2VuIExlbWlldXg=?= | last post by:
I would like a Beta copy of my software to expire after seven days from install. I use Clickonce for installing my applications. How can I determine the install date of a Clickonce application. -- Kenneth Lemieux Project Engineer Whelen Engineering Co., Inc.
0
7647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7859
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7618
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5472
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2068
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1181
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.