Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

windows 2003 eval 1

Status
Not open for further replies.

koolage

IS-IT--Management
Jan 3, 2005
60
Hello All,

is there a way to find out how many days are left on the installed eval copy of Windows Server 2003??

thanks in advance,

~Koolage
 
You can use WMI to figure it out.

I just love problems like this. Here it is:

Code:
'==========================================================================
'
' NAME: Report180DayExpiration.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL   : [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 2/15/2006
'
' COMMENT: <comment>
'
'==========================================================================
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
    installDate = dConvertWMItoVBSDate(objItem.InstallDate)
Next
	expireDate = installDate + 180
	daysToExpiration = DateDiff("d",Now, expireDate)

Report = "Windows was installed on " & installDate & vbCrLf
Report = Report & "and expires on " & expireDate & "." & vbCrLf
Report = Report & "There are " & daysToExpiration & " days left until expiration."

MsgBox Report

Private Function dConvertWMItoVBSDate(sDate)
  Dim sMonth, sDay, sYear, sHour, sMinutes, sSeconds
  sMonth = Mid(sDate,5,2)
  sDay = Mid(sDate,7,2)
  sYear = Mid(sDate,1,4)
  sHour = Mid(sDate,9,2)
  sMinutes = Mid(sDate,11,2)
  sSeconds = Mid(sDate,13,2)
  dConvertWMItoVBSDate = DateSerial (sYear, sMonth, sDay) + TimeSerial (sHour, sMinutes, sSeconds)
End Function

I hope you find this post helpful.

Regards,

Mark
 
Mark,
thanks a lot!! I'm looking into scripting to automate some things, I'll try this out as soon as I get to my box.


~Koolage
 
Mark,

Thanks again, I finally hadthe time to try it out. and here is your beautiful handy-work
check it out!!


180.jpg


Thanks again for your quick response and helpfulness!!

~koolage
 
Always happy to be of service.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top