cmd文件到hta

我有很多我每天使用的cmd文件,例如将用户添加到本地组,安装打印机,作为pipe理任务运行等。

我喜欢把我最经常使用的脚本添加到一个带标签的hta文件中,但是我很难find一个很好的指导方法来解决这个问题。 任何人有一个很好的网站与我分享?

或者我终于不得不开始与VB脚本? 我已经做了一些,但是为我做一个cmd文件要快得多。

如果您想在HTA中使用选项卡式界面,我强烈build议您使用Microsoft mpc DHTML行为库。

它简化了这个过程。 它可能看起来很复杂,但说实话,使用起来非常简单。 微软提供了一个很好的例子,你可以很容易地适应HTA。 只需从这里下载库文件(请注意该文件是一个自提取器),并遵循这个例子,我从他们的例子(请注意看“控件”选项卡)创build:

<HTML xmlns:mpc> <HEAD> <TITLE>Behavior Library: Mpc</TITLE> <STYLE> @media all { mpc\:container { behavior:url(mpc.htc); } mpc\:page { behavior:url(mpc.htc); } } H1 { font: bold 18pt verdana; color: navy } P { font: 10pt verdana; } A:link { color:#003399; text-decoration:none; } A:visited { color:#6699CC; text-decoration:none; } A:hover { text-decoration:underline; } </STYLE> <SCRIPT LANGUAGE="JavaScript"> function TabOrientation() { if(oMPC.style.tdTabOrientation == "top")oMPC.style.tdTabOrientation = "bottom" ; else oMPC.style.tdTabOrientation = "top" } function Height() { alert(parseInt(heightBox.value)); oMPC.style.height = parseInt(heightBox.value); } function Width() { oMPC.style.width = parseInt(widthBox.value); } function BackColor() { oMPC.style.backgroundColor = BackColorBox.value; } function Color() { oMPC.style.color = ColorBox.value; } </SCRIPT> <SCRIPT LANGUAGE="VBScript"> set objShell = CreateObject("Wscript.Shell") Sub runCmd() message = "Hello" objShell.Run "cmd /k echo " & message, 1, True End Sub </SCRIPT> </HEAD> <BODY BGCOLOR="white" ONLOAD="oMPC.style.visibility='visible'"> <!--TOOLBAR_START--><!--TOOLBAR_EXEMPT--><!--TOOLBAR_END--> <H1>MPC</H1> <FONT FACE="verdana,arial,helvetica" SIZE=1> <A href="#" onclick=self.close()><IMG ALIGN="middle" SRC="demo.gif" WIDTH="16" HEIGHT="16" BORDER="0" ALT="Click to Close Sample"></A> &nbsp;<A href="#" onclick=self.close()>Close This Sample</A> </FONT><HR> <P>Use the Mpc Behavior to group information on a page.</P> <BR><BR> <DIV STYLE="height:250"> <mpc:container ID="oMPC" STYLE="width:400; height:250; visibility:hidden"> <mpc:page ID="tab1" TABTITLE="This is a title" TABTEXT="Table"> <br><br> <table BORDER="1" ALIGN="CENTER" STYLE="font:10pt Verdana; width:300; height:79; color:black"> <tr> <td VALIGN="MIDDLE" ALIGN="CENTER"> <b>This is a table</b> </td> </tr> <tr> <td>Item One</td> </tr> <tr> <td>Item Two</td> </tr> <tr> <td>Item Three</td> </tr> </table> <br><br> </mpc:page> <mpc:page TABTITLE="This is a title, also" TABTEXT="Some Text"> <div STYLE="padding:12px; font:10pt Comic MS Sans; font-style:italic">This is some sample text...</div> </mpc:page> <mpc:page ID="tab3" TABTITLE="Title" TABTEXT="Controls"> <div STYLE="padding:12px; font:bold 10pt Verdana; color:black"> <span STYLE="width:100%; text-align:center">A Control Panel</span> <table ALIGN="CENTER" STYLE="font:normal 10pt Verdana"> <tr> <td>Radio Button</td> <td><input TYPE="RADIO" id="RADIO1" name="RADIO1"></td> </tr> <tr> <td>Checkbox</td> <td><input TYPE="CHECKBOX" CHECKED id="CHECKBOX1" name="CHECKBOX1"></td> </tr> <tr> <td>Input Box</td> <td><input TYPE="TEXT" id="TEXT1" name="TEXT1"></td> </tr> <tr> <td>Msg Button</td> <td><input TYPE="button" id="Button1" name="Button1" onclick='vbscript:MsgBox("Hello")' ></td> </tr> <tr> <td>Cmd Button</td> <td><input TYPE="button" id=Button3 name="Button1" onclick='vbscript:runCmd()' ></td> </tr> </table> </div> </mpc:page> <mpc:page TABTITLE="Title" TABTEXT="Image"> <img STYLE="position:absolute; top:50; left:50; width:100; height:60" SRC="flag.gif" WIDTH="171" HEIGHT="80"> </mpc:page> </mpc:container> </DIV> </BODY> </HTML> 

HTA文件真的是最好的select? 如果是这样的话,你需要学习一些VB,如果你想从HTA文件运行任何东西(你也可以用JavaScript来完成同样的事情)。

HTA只是一个像应用程序一样运行的HTML文件,所以如果你想要“标签”的意见,那么它可能会比它的价值更麻烦。

试试我在这里find的一个例子。