![在用户计算机上显示弹出(HTA)消息](https://linux22.com/image/1544490/%E5%9C%A8%E7%94%A8%E6%88%B7%E8%AE%A1%E7%AE%97%E6%9C%BA%E4%B8%8A%E6%98%BE%E7%A4%BA%E5%BC%B9%E5%87%BA%EF%BC%88HTA%EF%BC%89%E6%B6%88%E6%81%AF.png)
这是我的问题。我的公司正在从 MSP 那里收回我们的帮助台,我们需要能够每天多次向 HR 和 LP 显示弹出式 HTA 消息。
我知道每个人都会对此感到畏缩,但我们有大约 1500 台未加入域的 Windows 7 Pro 计算机(不是我的选择)。我们正在使用 LogMeIn Central Premiere,我可以使用它来部署脚本。每台计算机上的用户名都相同,他们不是管理员组的成员,只是用户组的成员。我希望能够在上午 10 点、下午 1 点和下午 4 点弹出消息,但似乎无法让 HTA 文件显示在运行批处理文件的计算机上。
为了在办公室进行测试,我将 psexec 从我的机器运行到我的测试机器上,它可以通过命令行正常打开(hta 文件在每台机器上本地保存)。这似乎与系统 0 有关,我希望过去有人可能已经解决了这个问题。
我也一直在尝试创建一个计划任务来调用 hta 文件,但是当用户登录时该文件再次没有显示正在运行。
任何帮助,将不胜感激。
答案1
我以前做过类似的事情,展示HTA 消息在视窗计算机使用批处理脚本,所以我想我会与您分享我的例子,您可以根据需要进行调整,以防它对您的问题有所帮助。
本质上,这会构建一个动态 HTA 文件,然后使用以下代码执行它:脚本
批处理脚本示例
HTA 标题和三行正文是此批处理脚本示例中顶部设置的变量。计时器用于设置消息自动关闭前的秒数。
您应该能够使用此逻辑作为起点,并根据您的需要进行相应调整。您可以将 HTA 文件逻辑放入批处理中,复制它,然后调用或任何其他我认为可以做到的事情。
IF NOT DEFINED MINIMIZED SET MINIMIZED=1 && START "" /MIN "%~dpnx0" %* && EXIT
@ECHO OFF
SET MsgTitle=Hey! Here is a Title!
SET MsgLine1=Hey! Here is a message!
SET MsgLine2=Message Line Two.
SET MsgLine3=Message Line Three.
::: -- Set the number in seconds you want the window to close
SET CloseTimer=5
SET TmpHTAFile=%tmp%\tmp.hta
SET TmpVBSFile=%tmp%\tmp.vbs
IF EXIST "%TmpHTAFile%" DEL /Q /F "%TmpHTAFile%"
IF EXIST "%TmpVBSFile%" DEL /Q /F "%TmpVBSFile%"
ECHO ^<html^> >> "%TmpHTAFile%"
ECHO ^<head^> >> "%TmpHTAFile%"
ECHO ^<hta:application >> "%TmpHTAFile%"
ECHO APPLICATIONNAME = "Message Alert" >> "%TmpHTAFile%"
ECHO ID = "Message Alert" >> "%TmpHTAFile%"
ECHO BORDERSTYLE = "Normal" >> "%TmpHTAFile%"
ECHO CAPTION = "No" >> "%TmpHTAFile%"
ECHO CONTEXTMENU = "No" >> "%TmpHTAFile%"
ECHO INNERBORDER = "No" >> "%TmpHTAFile%"
ECHO MAXIMIZEBUTTON = "No" >> "%TmpHTAFile%"
ECHO MINIMIZEBUTTON = "No" >> "%TmpHTAFile%"
ECHO NAVIGABLE = "No" >> "%TmpHTAFile%"
ECHO SCROLL = "No" >> "%TmpHTAFile%"
ECHO SCROLLFLAT = "No" >> "%TmpHTAFile%"
ECHO SELECTION = "No" >> "%TmpHTAFile%"
ECHO SHOWINTASKBAR = "No" >> "%TmpHTAFile%"
ECHO SINGLEINSTANCE = "Yes" >> "%TmpHTAFile%"
ECHO SYSMENU = "No"/^> ^<STYLE^> >> "%TmpHTAFile%"
ECHO html, body { >> "%TmpHTAFile%"
ECHO background color: #000000 >> "%TmpHTAFile%"
ECHO font-size: 90%; >> "%TmpHTAFile%"
ECHO line-height: 2.1em; >> "%TmpHTAFile%"
ECHO margin: 10; >> "%TmpHTAFile%"
ECHO padding: 0; >> "%TmpHTAFile%"
ECHO } >> "%TmpHTAFile%"
ECHO h1 {font-family: Arial; >> "%TmpHTAFile%"
ECHO color: #FF0000; >> "%TmpHTAFile%"
ECHO font-size: 3em; >> "%TmpHTAFile%"
ECHO text-align: center; >> "%TmpHTAFile%"
ECHO } >> "%TmpHTAFile%"
ECHO h2 {font-family: Arial; >> "%TmpHTAFile%"
ECHO color: #ffffff; >> "%TmpHTAFile%"
ECHO font-size: 1.5em; >> "%TmpHTAFile%"
ECHO text-align: left; >> "%TmpHTAFile%"
ECHO } >> "%TmpHTAFile%"
ECHO h3 >> "%TmpHTAFile%"
ECHO {font-family: Arial; >> "%TmpHTAFile%"
ECHO color: #666666; >> "%TmpHTAFile%"
ECHO font-size: 1em; >> "%TmpHTAFile%"
ECHO text-align: center; >> "%TmpHTAFile%"
ECHO } >> "%TmpHTAFile%"
ECHO ^</STYLE^> ^<script type='text/vbscript'^> Sub Window_onload() >> "%TmpHTAFile%"
ECHO me.ResizeTo 500,280 >> "%TmpHTAFile%"
ECHO me.MoveTo Screen.Width /2 - 300,Screen.Height / 2 - 300 >> "%TmpHTAFile%"
ECHO me.SetTimeout "Me.Close()",%CloseTimer%000 >> "%TmpHTAFile%"
ECHO End Sub >> "%TmpHTAFile%"
ECHO ^</script^> >> "%TmpHTAFile%"
ECHO ^</head^> >> "%TmpHTAFile%"
ECHO ^<body scroll="no"^> >> "%TmpHTAFile%"
ECHO ^<br^> >> "%TmpHTAFile%"
ECHO ^<h1^>%MsgTitle%^</h1^> >> "%TmpHTAFile%"
ECHO ^<h2^>%MsgLine1%^<br^> >> "%TmpHTAFile%"
ECHO %MsgLine2%^<br^> >> "%TmpHTAFile%"
ECHO %MsgLine3%^</h2^> >> "%TmpHTAFile%"
ECHO ^<h3^>close in %CloseTimer% seconds^</h3^> >> "%TmpHTAFile%"
ECHO ^<script type="text/javascript"^> >> "%TmpHTAFile%"
ECHO ^</script^> >> "%TmpHTAFile%"
ECHO ^</body^> >> "%TmpHTAFile%"
ECHO ^</html^> >> "%TmpHTAFile%"
ECHO Set objShell = Wscript.CreateObject("Wscript.Shell") >> "%TmpVBSFile%"
ECHO objShell.Run ("%TmpHTAFile%") >> "%TmpVBSFile%"
wscript "%TmpVBSFile%"
DEL /Q /F "%TmpVBSFile%"