PwExpChk.vbs can I add a company logo?

吃可爱长大的小学妹 提交于 2019-12-02 11:09:06

I based this on mockmyberet/ChooseFile.vbs

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 & "\PasswordExpirationDialog.hta"
    Set HtaFile = fso.CreateTextFile(HTAFileName, True)
    With HtaFile
        .writeline("<html><head>")
        .writeline("<title>PASSWORD EXPIRATION WARNING!</title>")
        .writeline("<HTA:APPLICATION ID='PaswordDialog'/></head><script language='VBScript'>")

        .writeline("Sub Window_OnLoad")
        .writeline("window.resizeto 700,400")
        .writeline("End Sub")

        .writeline("</script><body bgcolor='white'>")
        .writeline("<image src='https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/New_Orleans_Saints.svg/1000px-New_Orleans_Saints.svg.png' width='72' height='72' />")
        .writeline("<h1>")
        .writeline("Password Expires in " & daysLeft & " day(s)" & " at " & whenPasswordExpires)
        .writeline("<br><br>Once logged in, press CTRL-ALT-DEL and")
        .writeline("<br>select the 'Change a password' option")

        .writeline("<center><button onclick='Self.Close'>Okay</button></center>")
        .writeline("</h1></body></html>")
        .Close
    End With
    Set HtaFile = Nothing

    Set objShell = CreateObject("WScript.Shell")
    objShell.Run "%windir%\SysWoW64\mshta.exe " & Chr(34) & HTAFileName & Chr(34)

    WScript.Sleep 500
    fso.DeleteFile HTAFileName, True
    Set objShell = Nothing

End Sub

Usage

PasswordExpirationDialog 4, Date+ 4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!