我有一个非常简单的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运行时,我们将不胜感激。
此致
下进行。
答案 0 :(得分:1)
它为我工作。我必须将X改为C才能启动CMD。我改成了WshShell.Run "%systemroot%\system32\cmd.exe
轻微的事情:你错过了开始和结束<html>
(这可能是代码编辑器在这里做的那样)而且我也会把所有脚本放在最后。我还建议在每个Sub的末尾加Set WshShell = Nothing
。也不确定为什么你围绕每个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>