0
请帮助我试图在我们的网络上的另一台计算机上显示消息我们不能使用网络发送,因为在Windows 7上不存在,我们不能使用MSG,因为是禁用,并且如果我们启用它,GPO将禁用它。所以我在用户的计算机上显示消息的vbscript,以及另一个发送要显示的消息的vbscript。当我使用此代码来发送消息作为一个普通的VBScript它的工作原理vbscript不能在hta上工作
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>
请帮忙?
谢谢你的建议,我删除了旁边的错误恢复,并在两地行延续,但脚本仍然这样做。 – user1766952 2013-03-21 11:53:35
您的HTA在3个地方有续行。如果在解决该问题后仍然出现错误,请使用更正的代码和实际的错误消息来更新您的问题。 – 2013-03-21 11:59:51
我很抱歉无法回答,但是我删除了所有行延续,问题是我没有得到任何类型的错误,它只是打开cmd,并显示在工具栏上的脚本部分几秒钟然后它死了谢谢 – user1766952 2013-03-26 18:37:29