vbscript在hta上不起作用

vbscript在hta上不起作用,vbscript,hta,Vbscript,Hta,请帮助我尝试在我们网络上的另一台计算机上显示消息,我们无法使用net send,因为windows 7上不存在,我们无法使用MSG,因为它是禁用的,如果我们启用它,GPO将禁用它。因此,我在用户的计算机上有一个显示消息的vbscript,另一个vbscript发送要显示的消息。当我使用此代码作为常规vbscript发送消息时,它可以正常工作 Dim strMessage, strComputer, strLocalPath, strFile, objShell Dim strRemotePat

请帮助我尝试在我们网络上的另一台计算机上显示消息,我们无法使用net send,因为windows 7上不存在,我们无法使用MSG,因为它是禁用的,如果我们启用它,GPO将禁用它。因此,我在用户的计算机上有一个显示消息的vbscript,另一个vbscript发送要显示的消息。当我使用此代码作为常规vbscript发送消息时,它可以正常工作

Dim strMessage, strComputer, strLocalPath, strFile, objShell 
Dim strRemotePath, objShellApp, strTest, sPSEXEC
strComputer = InputBox("enter computer Name", "create File")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & 
strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
Set objShell = CreateObject("WScript.Shell")
Set objShellApp = CreateObject("Shell.Application")
currentpath = objShell.CurrentDirectory & "\"
sPSEXEC = currentPath & "psexec.exe"
strFile = """c:\windows\notification.vbs"""
strMessage = InputBox("enter Message", "create File")
strTest = "\\"&strComputer&" " &"cscript.exe"&" "&strFile&" 
"&"/message:"&Chr(34)&strMessage&Chr(34)
WScript.Echo strTest
objShellApp.ShellExecute "cmd.exe","/k "&sPSEXEC&" -s -i -d "&" "&strTest, "","runas",1
但将相同的代码放在hta上,它尝试在用户计算机上打开脚本,但它在显示消息之前就死了

<script Language = VBScript>
On Error Resume Next
Sub WindowsLoad
Dim strMessage, strComputer, strLocalPath, strFile, objShell
Dim strRemotePath, objShellApp, strTest, sPSEXEC    
strComputer = computerName.Value
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & 
_strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
Set objShell = CreateObject("WScript.Shell")
Set objShellAPP = CreateObject("Shell.Application")
currentpath = objShell.CurrentDirectory & "\"
sPSEXEC = currentPath & "psexec.exe"
strFile = """c:\windows\notification.vbs"""
strTest = "\\"&strComputer&" " &"cscript.exe"&" "&strFile&"   
_"&"/message:"&Chr(34)&strMessage&Chr(34)
objShellApp.ShellExecute "cmd.exe","/k "&sPSEXEC&" -s -i -d "&" "&strTest, "", 
_"runas", 1
End Sub
</script>
<Body>
<div>
</div>

Computer Name: <Input align="right" Type = "Text" Name = "computerName">
</br>
</br>
Message: 
</br>
<TEXTAREA NAME="Message" COLS=30 ROWS=6>

</TEXTAREA>
</br>
</br>
<Input Type = "Button" Value = "Send Message" Name = "Run_Button" onClick = "WindowsLoad"><P>

请帮助?

首先也是最重要的一点:下一步的全局错误恢复是万恶之源。除非您确切知道自己在做什么以及如何处理可能发生的任何错误,否则不要使用此选项

也就是说,您的脚本可能会死掉,因为HTA中的VBScript代码无效。如果要使用行继续,下划线必须位于要继续的行的末尾,而不是续行的开头:

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & 
_strComputer & "\root\cimv2")
此外,不能在字符串中使用行继续:

strTest = "\\"&strComputer&" " &"cscript.exe"&" "&strFile&"   
_"&"/message:"&Chr(34)&strMessage&Chr(34)

谢谢你的建议,我删除了错误恢复下一步,行继续在两个地方,但脚本仍然做相同的。你的HTA有行继续在3个地方。如果在修复该问题后仍然出现错误,请使用更正的代码和实际错误消息更新您的问题。很抱歉,无法回复,但是的,我删除了所有的行连续体,问题是,我没有得到任何类型的错误,只需打开cmd并在工具栏上显示脚本部分几秒钟,然后它就消失了。如果我没有弄错,我要求您使用更正的HTA代码更新您的问题,即您现在使用的代码。