Vbscript 需要密码才能关闭HTA

Vbscript 需要密码才能关闭HTA,vbscript,passwords,hta,locked,Vbscript,Passwords,Hta,Locked,我希望有人能向我证明一些方向。我想将我创建的应用程序启动器设置为需要关闭密码。感谢您提供的任何帮助。 但是这里有一些不完整的代码来告诉你我的目的 Set objShell = CreateObject("Wscript.Shell") dim password password=InputBox("Please Enter Password:","3 - Tries Left") if password = ("9999") then dim correct correct =MsgB

我希望有人能向我证明一些方向。我想将我创建的应用程序启动器设置为需要关闭密码。感谢您提供的任何帮助。 但是这里有一些不完整的代码来告诉你我的目的

Set objShell = CreateObject("Wscript.Shell")
dim password
password=InputBox("Please Enter Password:","3 - Tries Left")
if password = ("9999") then 
    dim correct correct =MsgBox("Correct Password!",64,"correct")
    objShell.Run("shutdown /m shutdown -r -f -t 0")
Else 
    dim again
    again =MsgBox("Incorrect Password! Do You Want To Try Again?",53,"Incorrect Password!")
    If again = 4 Then
        dim password2
        password2=InputBox("Please Enter Password:","2 - Tries Left")
        if password2 = ("9999") then
            dim correct2 
            correct2 =MsgBox("Correct Password!",64,"correct") 

对不起!我无法发布所有代码。我只需要知道如何关闭现有窗口。我想告诉它关闭MSHTA.EXE会起作用。

试试这个HTA,我希望它能成功

NB:密码是9999,您当然可以在此行中更改密码
MyGoodPassword=“9999”


选项显式
Dim标题、ws、Voice、ErrorMsg、WelcomeMsg、MyGoodPassword、密码、Temp、测试、ProcessEnv、用户名
Title=“访问系统©Hackoo 2015”
Dim objFSO:Set objFSO=CreateObject(“Scripting.FileSystemObject”)
设置ws=CreateObject(“wscript.Shell”)
设置ProcessEnv=Ws.Environment(“进程”)
用户名=ProcessEnv(“用户名”)
Temp=WS.ExpandEnvironmentStrings(“%Temp%”)
Tests=Temp&“\Tests.txt”
'------------------------------------------------------------------------------------
子窗口_onload()
中心窗口280180
调用密码形式()
呼叫文本焦点
Dim计数:计数=0
如果不存在objFSO.FileExists(Tests),则
Dim Logfile:Set Logfile=objFSO.OpenTextFile(Tests,2,True)
Logfile.writeline计数
日志文件,关闭
如果结束
调用Kill(“Explorer.exe”)
调用DisableTaskMgr()
端接头
'------------------------------------------------------------------------------------
副中心窗口(x,y)
伊托普
window.resizeTo x,y
iLeft=window.screen.availWidth/2-x/2
itop=window.screen.availHeight/2-y/2
window.moveTo ileft,itop
端接头
'------------------------------------------------------------------------------------
子密码形式()
Self.document.title=“访问系统©Hackoo 2015”
Self.document.bgColor=“DarkOrange”
ONSCR.InnerHTML=“键入密码

”_ &"" 端接头 '------------------------------------------------------------------------------------ 子检查密码 尺寸NB_测试最大值:NB_测试最大值=3 Dim Readfile、计数、剩余NB_测试、日志文件、控件、命令、执行器、MSGNUMBTEST、MsgReboot Set Voice=CreateObject(“SAPI.SpVoice”) ErrorMsg=“注意!!!”&vbcr&“密码错误!”&vbcr&“重试!” WelcomeMsg=“再次欢迎”&DblQuote(用户名)&“在您的系统中!” MyGoodPassword=“9999” Set Readfile=objFSO.OpenTextFile(测试,1) Count=Readfile.ReadAll Readfile.Close Controle=True 而控制 计数=计数+1 NB_测试_剩余=NB_测试_最大-计数 设置Logfile=objFSO.OpenTextFile(Tests,2,True) Logfile.writeline计数 日志文件,关闭 如果PasswordArea.Value为MyGoodPassword,则 语音,说错话 ws.Popup ErrorMsg,“1”,标题,0+16 MsgNumbTests=“注意!!!”&vbcr&“密码不正确,测试的注意事项是”&Count&“&vbcr&_ “剩余测试数为”&NB\u剩余测试数 语音,说MSGNUMB MsgBox MsgNumbTests,48,标题 睡眠(1) 位置。重新加载(True) 如果结束 如果PasswordArea.Value=MyGoodPassword,则 如果objFSO.FileExists(Tests),则objFSO.deletefiletests,True Controle=False 声音,欢迎发言 ws.Popup WelcomeMsg,“1”,标题,0+64 调用启动(“Explorer.exe”) 调用EnableTaskMgr() 自我封闭 出口接头 如果结束 如果计数=NB\u测试\u最大值,则 如果objFSO.FileExists(Tests),则objFSO.deletefiletests,True Voice.Speak“计算机将在30秒内重新启动!” MsgReboot=“已达到测试数量限制!”&vbcr&“计算机将在30秒后重新启动!” MsgBox MsgReboot,48,“已达到测试数量限制!” Command=“cmd/c Shutdown.exe-r-t 30-c”&chr(34)&“计算机将在30秒后重新启动!”&chr(34) Executer=WS.Run(命令,0,False) 窗户关上 如果结束 出口接头 温德 端接头 '---------------------------------------------------------------------------------- 子文本焦点 密码区,焦点 端接头 '---------------------------------------------------------------------------------- 分段压井(工艺) Dim Ws、命令、执行 设置Ws=CreateObject(“Wscript.Shell”) Command=“cmd/c Taskkill/F/IM”&Process&“ Execution=Ws.Run(命令,0,False) 端接头 '---------------------------------------------------------------------------------- 次级发射(过程) Dim Ws、命令、执行 设置Ws=CreateObject(“Wscript.Shell”) Command=“cmd/c Start”&进程 Execution=Ws.Run(命令,0,False) 端接头 '----------------------------------------------------------------------------------- '-----------------------------------EnableTaskMgr---------------------------------------- 子启用任务管理器() Dim WshShell,系统 System=“HKEY\U CURRENT\U USER\Software\Microsoft\Windows\CurrentVersion\Policys\System\” 设置WshShell=CreateObject(“WScript.Shell”) Wshshell.RegWrite系统,“REG_SZ” WshShell.RegWrite系统&“\DisableTaskMgr”,0,“REG\u DWORD” 端接头 '------------------------------------------------------------------------------------ “-------------------------------DisableTaskMgr----------------------------------------- 子DisableTaskMgr() Dim WshShell,系统 System=“HKEY\U CURRENT\U USER\Software\Microsoft\Windows\CurrentVersion\Policys\System\” 设置WshShell=CreateObject(“WScript.Shell”) Wshshell.RegWrite系统,“RE

<HTML>
<HEAD>
<TITLE></TITLE>
<HTA:APPLICATION
APPLICATIONNAME="Access to the system © Hackoo © 2015"
BORDER="THIN"
BORDERSTYLE="NORMAL"
ICON="Explorer.exe"
INNERBORDER="NO"
MAXIMIZEBUTTON="NO"
MINIMIZEBUTTON="NO"
SCROLL="NO"
SELECTION="NO"
SINGLEINSTANCE="YES"/>
</HEAD>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<BODY TOPMARGIN="1" LEFTMARGIN="1"><CENTER><DIV><SPAN ID="ONSCR"></SPAN></DIV></CENTER></BODY>
<SCRIPT LANGUAGE="VBScript">
Option Explicit
Dim Title,ws,Voice,ErrorMsg,WelcomeMsg,MyGoodPassword,Password,Temp,Tests,ProcessEnv,UserName
Title = "Access to the system © Hackoo 2015"
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("wscript.Shell")
Set ProcessEnv = Ws.Environment("Process")
UserName = ProcessEnv("USERNAME")
Temp = WS.ExpandEnvironmentStrings("%Temp%")
Tests = Temp &"\Tests.txt"
'------------------------------------------------------------------------------------
Sub window_onload()
    CenterWindow 280,180
    Call PasswordForm()
    Call TextFocus
    Dim Count : Count = 0
    If Not objFSO.FileExists(Tests) Then
        Dim Logfile : Set Logfile = objFSO.OpenTextFile(Tests,2,True)
        Logfile.writeline Count
        Logfile.Close
    end If
   Call Kill("Explorer.exe")
   Call DisableTaskMgr()
End Sub
'------------------------------------------------------------------------------------
Sub CenterWindow(x,y)
    Dim iLeft,itop
    window.resizeTo x,y
    iLeft = window.screen.availWidth/2 - x/2
    itop = window.screen.availHeight/2 - y/2
    window.moveTo ileft,itop
End Sub
'------------------------------------------------------------------------------------
Sub PasswordForm()
    Self.document.title = "Access to the system © Hackoo 2015"
    Self.document.bgColor = "DarkOrange"
    ONSCR.InnerHTML="<center><FONT COLOR=""#FFFFFF"" SIZE=""+1"" FACE=""VERDANA,ARIAL,HELVETICA,SANS-SERIF"">Type your Password</FONT><br><br><input type=""password"" name=""PasswordArea"" size=""20"" onKeyUp=""TextFocus""><P>"_
    &"<input  type=""Submit"" STYLE=""HEIGHT:25;WIDTH:190"" value=""Access to the system"" name=""run_button""  onClick=""CheckPassword"">"
END Sub
'------------------------------------------------------------------------------------
Sub CheckPassword
    Dim NB_Tests_MAX : NB_Tests_MAX = 3
    Dim Readfile,Count,NB_Tests_Remaining,Logfile,Controle,Command,Executer,MsgNumbTests,MsgReboot
    Set Voice = CreateObject("SAPI.SpVoice")
    ErrorMsg = "ATTENTION ! ! ! "& vbcr &"The Password is Wrong ! "& vbcr &"Try Again !"
    WelcomeMsg = "Welcome again "& DblQuote(UserName) &" in your System !"
    MyGoodPassword = "9999"
    Set Readfile = objFSO.OpenTextFile(Tests,1)
    Count = Readfile.ReadAll
    Readfile.Close
    Controle = True
    While Controle
        Count = Count + 1
        NB_Tests_Remaining = NB_Tests_MAX - Count
        Set Logfile = objFSO.OpenTextFile(Tests,2,True)
        Logfile.writeline Count
        Logfile.Close
        If PasswordArea.Value <> MyGoodPassword Then
            Voice.Speak ErrorMsg
            ws.Popup ErrorMsg,"1",Title,0+16
            MsgNumbTests =  "ATTENTION !!! "&vbcr&"Bad Password and NB°of TESTS is " & Count &"."&vbCr&_
            "The remaining number of tests is "& NB_Tests_Remaining
            Voice.Speak MsgNumbTests
            MsgBox MsgNumbTests,48,Title
            Sleep(1)
            Location.Reload(True)
        end if
        If PasswordArea.Value = MyGoodPassword Then
            If objFSO.FileExists(Tests) Then objFSO.DeleteFile Tests,True
            Controle = False
            Voice.Speak WelcomeMsg
            ws.Popup WelcomeMsg,"1",Title,0+64
            Call Launch("Explorer.exe")
            Call EnableTaskMgr()
            Self.Close
            Exit Sub
        End If
        If Count = NB_Tests_MAX Then
            If objFSO.FileExists(Tests) Then objFSO.DeleteFile Tests,True
            Voice.Speak "The computer will reboot in 30 seconds !"
            MsgReboot = "The Limit number of tests is reached ! "&vbcr& "The computer will Reboot in 30 seconds !"
                       MsgBox MsgReboot,48,"The Limit number of tests is reached ! "
                       Command="cmd /c Shutdown.exe -r -t 30 -c " & chr(34) & "The computer will reboot in 30 seconds !" & chr(34)
                       Executer = WS.Run(Command,0,False)
                       window.close
        End If
            Exit Sub
        wend
    End Sub
'----------------------------------------------------------------------------------
    Sub TextFocus
        PasswordArea.Focus
    End Sub
'----------------------------------------------------------------------------------
    Sub Kill(Process)
        Dim Ws,Command,Execution
        Set Ws = CreateObject("Wscript.Shell")
        Command = "cmd /c Taskkill /F /IM "&Process&""
        Execution = Ws.Run(Command,0,False)
    End Sub
'----------------------------------------------------------------------------------
    Sub Launch(Process)
        Dim Ws,Command,Execution
        Set Ws = CreateObject("Wscript.Shell")
        Command = "cmd /c Start "&Process&""
        Execution = Ws.Run(Command,0,False)
    End Sub
'-----------------------------------------------------------------------------------
'------------------------------EnableTaskMgr----------------------------------------
    Sub EnableTaskMgr()
        Dim WshShell,System
        System="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\"
        Set WshShell=CreateObject("WScript.Shell")
        Wshshell.RegWrite System, "REG_SZ"
        WshShell.RegWrite System &"\DisableTaskMgr", 0, "REG_DWORD"
    End sub
'------------------------------------------------------------------------------------
'-----------------------------DisableTaskMgr-----------------------------------------
    Sub DisableTaskMgr()
        Dim WshShell,System
        System="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\"
        Set WshShell=CreateObject("WScript.Shell")
        Wshshell.RegWrite System, "REG_SZ"
        WshShell.RegWrite System &"\DisableTaskMgr", 1, "REG_DWORD"
    End sub
'--------------------------------------------------------------------------------------
    Sub Sleep(intNumSecs)
' Because WScript.Sleep () is not available in HTA
' scripts, invoke a VBScript file to do the waiting.
        Dim strScriptFile, strCommand, intRetcode, objWS
        If intNumSecs <= 0 Then Exit Sub
        Set objWS = CreateObject ("WScript.Shell")
        strScriptFile = "%temp%\wait" & intNumSecs & "seconds.vbs"
        strCommand = "cmd /c ""echo WScript.Sleep " & intNumSecs * 1000 & " >" & strScriptFile & _
        "&start /wait """" wscript.exe " & strScriptFile & """"
        intRetCode = objWS.Run (strCommand, 0, True)
        If intRetCode = 0 Then Exit Sub
    End Sub
'---------------------------------------------------------------------------------------
    Function DblQuote(Str)
             DblQuote = Chr(34) & Str & Chr(34)
    End Function
'---------------------------------------------------------------------------------------
</SCRIPT>