title: Password Expiration notification vbscript
body: <p>I got great help from the link below, I have made a few changes but I can not get it to work, any thoughts? What it is supposed to do is go get the domain policy and check the password expiration information, if it is within the 14 day time frame it shows a popup (it works if I use msgbox) I want to use a company logo with the text, this is the problem area.</p>
  
  <p><a href="https://stackoverflow.com/questions/38231682/pwexpchk-vbs-can-i-add-a-company-logo">PwExpChk.vbs can I add a company logo?</a></p>
  
  <pre><code>'==========================================
   ' Check for password expiring notification
   '==========================================
   ' First, get the domain policy.
   '==========================================
   Dim oDomain
   Dim oUser
   Dim maxPwdAge
   Dim numDays
   Dim warningDays
  
  warningDays = 14
  
   Set LoginInfo = CreateObject("ADSystemInfo")  
   Set objUser = GetObject("LDAP://" &amp; LoginInfo.UserName &amp;)  
   strDomainDN = UCase(LoginInfo.DomainDNSName) 
   strUserDN = LoginInfo.UserName
  
  '========================================
   ' Check if password is non-expiring.
   '========================================
   Const ADS_UF_DONT_EXPIRE_PASSWD = &amp;h10000
   intUserAccountControl = objUser.Get("userAccountControl")
   If intUserAccountControl And ADS_UF_DONT_EXPIRE_PASSWD Then
       'WScript.Echo "The password does not expire."
   Else
  
       Set oDomain = GetObject("LDAP://" &amp; strDomainDN)
       Set maxPwdAge = oDomain.Get("maxPwdAge")
  
      '========================================
       ' Calculate the number of days that are
       ' held in this value.
       '========================================
       numDays = CCur((maxPwdAge.HighPart * 2 ^ 32) + _
                       maxPwdAge.LowPart) / CCur(-864000000000)
       'WScript.Echo "Maximum Password Age: " &amp; numDays
  
       '========================================
       ' Determine the last time that the user
       ' changed his or her password.
       '========================================
       Set oUser = GetObject("LDAP://" &amp; strUserDN)
  
      '========================================
       ' Add the number of days to the last time
       ' the password was set.
       '========================================
       whenPasswordExpires = DateAdd("d", numDays, oUser.PasswordLastChanged)
       fromDate = Date
       daysLeft = DateDiff("d",fromDate,whenPasswordExpires)
  
       'WScript.Echo "Password Last Changed: " &amp; oUser.PasswordLastChanged
  
      if (daysLeft &lt; warningDays) and (daysLeft &gt; -1) then
           Sub PasswordExpirationDialog(daysLeft, whenPasswordExpires)
  Dim fso, objShell,  HTAFileName, HtaFile
  Const TemporaryFolder = 2
  Const ForReading = 1
  
  Sub PasswordExpirationDialog(daysLeft, whenPasswordExpires)
  Dim fso, objShell,  HTAFileName, HtaFile
  Const TemporaryFolder = 2
  Const ForReading = 1
  
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set objTempFolder = fso.GetSpecialFolder(TemporaryFolder)
  HTAFileName = fso.GetSpecialFolder(TemporaryFolder).Path &amp; "c:\windows\temp\PasswordExpirationDialog.hta"
  Set HtaFile = fso.CreateTextFile(HTAFileName, True)
  With HtaFile
      .writeline("&lt;html&gt;&lt;head&gt;")
      .writeline("&lt;title&gt;PASSWORD EXPIRATION WARNING!&lt;/title&gt;")
      .writeline("&lt;HTA:APPLICATION ID='PaswordDialog'/&gt;&lt;/head&gt;&lt;script language='VBScript'&gt;")
  
      .writeline("Sub Window_OnLoad")
      .writeline("window.resizeto 700,400")
      .writeline("End Sub")
  
      .writeline("&lt;/script&gt;&lt;body bgcolor='white'&gt;")
      .writeline("&lt;image src='\\domain\netlogon\PwExpChk\Logo2.jpg' width='448' height='170' /&gt;&lt;br&gt;")
      .writeline("&lt;h2&gt;")
      .writeline("Password Expires in " &amp; daysLeft &amp; " day(s)" &amp; " at " &amp; whenPasswordExpires)
      .writeline("&lt;br&gt;&lt;br&gt;Once logged in, press CTRL-ALT-DEL and")
      .writeline("&lt;br&gt;select the 'Change a password' option&lt;br&gt;&lt;br&gt;")
  
      .writeline("&lt;center&gt;&lt;button onclick='Self.Close'&gt;Click_To_Close&lt;/button&gt;&lt;/center&gt;")
      .writeline("&lt;/h2&gt;&lt;/body&gt;&lt;/html&gt;")
      .Close
  End With
  Set HtaFile = Nothing
  
  Set objShell = CreateObject("WScript.Shell")
  objShell.Run "%windir%\System32\mshta.exe " &amp; Chr(34) &amp; HTAFileName &amp; Chr(34)
  
  WScript.Sleep 500
  fso.DeleteFile HTAFileName, True
  Set objShell = Nothing
  
  End Sub
       End if
  
  End if
  
  '========================================
   ' Clean up.
   '========================================
   Set oUser = Nothing
   Set maxPwdAge = Nothing
   Set oDomain = Nothing
  </code></pre>