【发布时间】:2013-03-20 18:06:43
【问题描述】:
请帮助我正在尝试在我们网络上的另一台计算机上显示消息我们无法使用网络发送,因为在 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>
请帮忙?
【问题讨论】: