跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 求助,如何虚拟机 windows 使用 apc PowerChute Business Edition 软件关闭 esxi 主机?
未分類
26 4 月 2020

求助,如何虚拟机 windows 使用 apc PowerChute Business Edition 软件关闭 esxi 主机?

求助,如何虚拟机 windows 使用 apc PowerChute Business Edition 软件关闭 esxi 主机?

資深大佬 : moneycwq 63

我使用 esxi 虚拟的 windows 2019 运行 apc PowerChute Business Edition,可以识别到 ups,该软件可以在断电后启动一个批处理命令,但是这个批处理不能进行桌面交互。我在 esxi 主机里做了一个 sh,我想通过 cmd 模式的 ssh 链接 esxi 主机,运行这个 sh,这个 sh 批处理关闭主机下的全部虚拟机,最后在关闭 esxi。为此做了一个 vbs 来完成,自动 ssh 链接 esxi 主机,自动启用 sh。单独点击这个 vbs 都可以完成任务,但是通过 apc PowerChute Business Edition 的软件启动批处理就无法运行。很困惑。不知道哪位可以指点迷津,让我可以在断电后自动关闭全部虚拟机,并关闭 esxi 主机。 ssh 使用 openssh,vbs 我这样写的,不知道对不对。是不是必须要编写成批处理才可以?但是我不懂 cmd 模式下的批处理,不知道怎么编写。希望得到帮助,谢谢

我写的 vbs Dim WshShell

Set WshShell=WScript.CreateObject(“WScript.Shell”)

WshShell.Run “cmd.exe”

WScript.Sleep 1500

WshShell.SendKeys “ssh [email protected]”

WshShell.SendKeys “{ENTER}”

WScript.Sleep 1500

WshShell.SendKeys “12345678”

WshShell.SendKeys “{ENTER}”

WScript.Sleep 1500

WshShell.SendKeys “cd /vmfs/volumes/datastore/UPS”

WshShell.SendKeys “{ENTER}”

WScript.Sleep 1500

WshShell.SendKeys “sh test.sh”

WshShell.SendKeys “{ENTER}”

apc 自己带的一个默认的 cmd 文件里面解释如下: rem This command file provides examples of proper command file syntax

rem 此命令文件提供了正确的命令文件规则的范例

rem Command Files run by PowerChute Business Edition must be placed in this directory.

rem 运行 PowerChute Business Edition 的命令文件必须放在此文件目录下

rem Use the full path name of executable programs and external command files.

rem 请采用可执行文件和外部命令文件名称(含所有目录路径)

rem The @START command must be used to run executable programs (see example below).

rem @START 开始命令必须用于运行可执行文件(如下所示)

rem For the @START command, path names that include spaces must be enclosed in quotes;

rem arguments for the executable must be outside the quotes. A double quote must

rem precede the quoted path name. For example, to execute a command file in

rem c:Program FilesAPCPowerChute Business Editionagentcmdfiles called myShut.exe,

rem the following line should be entered in the command file:

rem 对于 @START 开始命令, 有空格的路径名称必须包含在引用内,可执行的必须放到引用外.

rem 双重引用必须优先于引用路径名称,例如,运行 c:Program FilesAPCPowerChute Business Editionagentcmdfiles 目录下的命令文件 myShut.exe

rem 以下行应输入到命令文件中

rem @START “” “c:Program FilesAPCPowerChute Business EditionagentcmdfilesmyShut.exe”

rem time /T >> C:apctestcmdtest.txt

大佬有話說 (1)

  • 主 資深大佬 : moneycwq

    排版问题,我单独写一下写的 vbs 内容
    Dim WshShell
    Set WshShell=WScript.CreateObject(“WScript.Shell”)
    WshShell.Run “cmd.exe”
    WScript.Sleep 1500
    WshShell.SendKeys “ssh [email protected]”
    WshShell.SendKeys “{ENTER}”
    WScript.Sleep 1500
    WshShell.SendKeys “CHENyyrui*102437”
    WshShell.SendKeys “{ENTER}”
    WScript.Sleep 1500
    WshShell.SendKeys “cd /vmfs/volumes/datastore/UPS”
    WshShell.SendKeys “{ENTER}”
    WScript.Sleep 1500
    WshShell.SendKeys “sh test.sh”
    WshShell.SendKeys “{ENTER}”

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具