我有一个非常简单的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="HTAsbicon.ico"
>
</head>
<script language="VBScript">
'Sub Window_onLoad
'window.resizeTo 400,250
'End Sub
Sub Createimage
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "x:windowssystem32cmd.exe /c START /MIN image.cmd", 1 ,TRUE
End Sub
</script>
<script language="VBScript">
Sub RecoverPart
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "x:windowssystem32cmd.exe /c START /MIN part.cmd", 1 ,True
End Sub
</script>
<script language="VBScript">
Sub RecoverUSB
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "x:windowssystem32cmd.exe /c START /MIN usb.cmd", 1 ,TRUE
End Sub
</script>
<script language="VBScript">
Sub Reboot
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "X:windowssystem32cmd.exe /c START /MIN restart.cmd", 1 ,TRUE
End Sub
</script>
<script language="VBScript">
Sub Shutdown
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "x:windowssystem32cmd.exe /c START /MIN shutdwn.cmd", 1 ,TRUE
End Sub
</script>
<body bgcolor="#003E67">
<center><img src="HTASmartbox2.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 .
这对我来说很有效。我不得不将X更改为C,以便启动CMD。我把我的改成了WshShell.Run "%systemroot%system32cmd.exe
次要的事情:你错过了开始和结束<html>
(这可能是代码编辑器在这里做的),我也会把结束头在所有的脚本之后。我还建议在每个Sub的末尾添加一个Set WshShell = Nothing
。我也不知道为什么你在每个Sub周围创建了一个脚本部分,而不是一个大的,但它不会伤害我所知道的任何东西。
<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="Recovery"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
maximizeButton="no"
minimizeButton="no"
icon="HTAsbicon.ico"
>
<title>Recovery</title>
<script>
...
</script>
</head>