1

我有一个非常简单的 HTA 代码,它在 WinPE 5.1 下运行时生成一个菜单,基本上它只是屏幕上的 5 个按钮,每个按钮都应该调用一个 CMD 文件,但是没有任何反应。

    <head>
<title>Recovery</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Recovery"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="maximize"
     maximizeButton="no"
     minimizeButton="no"
     icon="HTA\sbicon.ico"

>
</head>

<script language="VBScript">

    'Sub Window_onLoad
        'window.resizeTo 400,250
    'End Sub        

    Sub Createimage
       Set WshShell = CreateObject("WScript.Shell")
       WshShell.Run "x:\windows\system32\cmd.exe /c START /MIN image.cmd", 1 ,TRUE
    End Sub
   </script>

   <script language="VBScript">
    Sub RecoverPart
        Set WshShell = CreateObject("WScript.Shell")
       WshShell.Run "x:\windows\system32\cmd.exe /c START /MIN part.cmd", 1 ,True
    End Sub
   </script>

   <script language="VBScript">
    Sub RecoverUSB
        Set WshShell = CreateObject("WScript.Shell")
       WshShell.Run "x:\windows\system32\cmd.exe /c START /MIN usb.cmd", 1 ,TRUE
    End Sub
   </script>

   <script language="VBScript">
    Sub Reboot
        Set WshShell = CreateObject("WScript.Shell")
       WshShell.Run "X:\windows\system32\cmd.exe /c START /MIN restart.cmd", 1 ,TRUE
    End Sub
   </script>

   <script language="VBScript">
    Sub Shutdown
        Set WshShell = CreateObject("WScript.Shell")
       WshShell.Run "x:\windows\system32\cmd.exe /c START /MIN shutdwn.cmd", 1 ,TRUE
    End Sub

</script>

<body bgcolor="#003E67">

    <center><img src="HTA\Smartbox2.jpg"/>

    <br><br><br>
    <input type="button" value="Create Image" name="run_button"  onClick="Createimage" style="Width: 300px; height: 75px; font-family: roboto; font-size: 25px;"><br><br>
    <input type="button" value="Recover From Partition" name="run_button"  onClick="RecoverPart" style="Width: 300px; height: 75px; font-family: roboto; font-size: 25px;"><br><br>
    <input type="button" value="Recover From USB" name="run_button"  onClick="RecoverUSB" style="Width: 300px; height: 75px; font-family: roboto; font-size: 25px;"><br><br>
    <input type="button" value="Restart Device" name="run_button"  onClick="Reboot" style="Width: 300px; height: 75px; font-family: roboto; font-size: 25px;"><br><br>
    <input type="button" value="Shutdown Device" name="run_button"  onClick="Shutdown" style="Width: 300px; height: 75px; font-family: roboto; font-size: 25px;"><br><br></Center>
</body>

任何帮助将不胜感激使 CMD 运行。

问候

C。

4

1 回答 1

1

它对我有用。不过,我必须将 X 更改为 C 才能启动 CMD。我把我的改成WshShell.Run "%systemroot%\system32\cmd.exe

次要的事情:你缺少开头和结尾<html>(这可能是这里的代码编辑器),我也会把结尾放在所有脚本之后。我还建议Set WshShell = Nothing在每个 Sub 的末尾添加一个。也不知道为什么你在每个 Sub 周围创建了一个脚本部分而不是一个大的,但它不会伤害我所知道的任何东西。

<html>
<head>    
<HTA:APPLICATION 
    APPLICATIONNAME="Recovery"
    SCROLL="no"
    SINGLEINSTANCE="yes"
    WINDOWSTATE="maximize"
    maximizeButton="no"
    minimizeButton="no"
    icon="HTA\sbicon.ico"
    >
<title>Recovery</title>
<script>
...
</script>
</head>
于 2015-10-27T15:43:32.477 回答