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