0

I have a lot of cmd files i use daily for example to add users to local groups, installing printers, run as admin tasks etc.

I like to take the scripts i use most frequently and add them to a tabbed hta file, but i have trouble finding a good guide on how to easily do it. Anyone having a good site to share with me?

Or do i finally have to start with vb scripting? I have done some but it's so much faster to do a cmd file for me.

  • 2
    This may need to be moved to stackoverflow? This sounds more related to programming then server admins. – Zoredache Nov 12 '09 at 01:03
  • Yes you're right. I just checked so for the first time and i agree that this kind of questions suits better there. – Frode Eskil Nov 12 '09 at 18:16

2 Answers2

1

If you want to use a tabbed interface within an HTA, I highly recommend that you use the Microsoft mpc DHTML behavior library.

It simplifies the process. It may look complex, but honestly it's really easy to use. Microsoft provides a great example from which you can easily adapt for HTA. Just download the library file from here (please note the file is a self extractor), and follow this example, which I created from their example (note look at the "Controls" tab):

<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>
mrTomahawk
  • 1,119
  • 1
  • 10
  • 17
0

Is a HTA file really the best option? If so, you'll need to learn some VB if you want to run anything from a HTA file (you could probably also accomplish the same thing with javascript).

HTA is just a HTML file that is run like an application, so if you want 'tabbed' views then it will probably be more hassle than it's worth.

Try an example I found here.

Michael Galos
  • 153
  • 1
  • 5
  • Thank you for the example, it's something i can use in my sysadmin.hta if i finish it sometime. I found a tabbed hta sometime ago and thought it would be nice to do a tool out of it. – Frode Eskil Nov 12 '09 at 18:37