Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA dynamically assign radio button to file in local directory

Status
Not open for further replies.

WRD

Technical User
Sep 23, 2021
1
0
0
US
I have an hta running vbs with three radio buttons. The objective is to have the radio button that's selected bring the file name in the working directory to be used as a variable.

Code
<head>
<title>Octapharma WinPE Tool </title>
<HTA:APPLICATION
ID="Octapharma WinPE Tool"
APPLICATIONNAME="Octapharma WinPE Tool "
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="NORMAL"
>
</head>

</HEAD>
<BODY BGCOLOR="#519BD2">
<FONT COLOR="White" FACE="Tahoma">


<SCRIPT LANGUAGE="VBScript">
'****************************************************************************
'* Globals
'* setup global script parameters
'****************************************************************************
Option Explicit
Dim objShell, strBody, strComputer, cmdline
Set objShell = CreateObject("WScript.Shell")


Sub doTask(doMe)
objShell.Run doMe
End Sub
Sub Apply_Image
If RadioOption(0).Checked Then
strComputer = RadioOption(0).Value
End If
If RadioOption(1).Checked Then
strComputer = RadioOption(1).Value
End If
If RadioOption(2).Checked Then
strComputer = RadioOption(2).Value
End If
If RadioOption(3).Checked Then
strComputer = RadioOption(3).Value
End If

If strComputer = "" Then
Exit Sub
End If

cmdline = Chr(34) & "%WINDIR%\system32\Imagex.exe" & Chr(34) & " imagex /apply f:\%1 1 h:" & Chr(34) & strComputer & Chr(34) & "," & Chr(34) & "-reboot"
doTask(cmdline)
'Next

End Sub

Sub diskpart
Dim oShell
Set oShell = CreateObject("WScript.Shell")
oShell.run "%WINDIR%\system32\diskpart.exe -s Z:\diskpart.txt",1,True
End Sub



'****************************************************************************
'* Reset
'* reset the tool interface, also reloads the code (helpful for programming)
'****************************************************************************
Sub Reset
Location.Reload(True)
End Sub
</script>
<!****************************************************************************>
<!* End Script / Begin HTML >
<!****************************************************************************>
<BODY>
<img src="Octa.jpg" alt="Logo" height="60" />
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<HTA:APPLICATION
APPLICATION="Yes"
APPLICATIONNAME="Windows PE Image Deplyment"
BORDER="Yes"
INNERBORDER="yes"
NAVIGABLE="Yes"
SCROLL="no"
SHOWINTASKBAR="Yes"
WINDOWSTATE="Maximize"></HTA:APPLICATION>


<H3>Select Image to Apply<H3>
<Table spacing=20 cellpadding=20 border=10>

<TR>
<TD><font color=black><INPUT type="radio" name="RadioOption" VALUE="\Kiosk\kiosk.wim">Kiosk</font></TD>
<TD><font color=black><INPUT type="radio" name="RadioOption" VALUE="\Mgmt\Mgmt.wim">Mgmt</font></TD>
<TD><font color=black><INPUT type="radio" name="RadioOption" value="\Console\console.wim">Console</front></TD>

<TD><font bit)</font></TD>
</TR>
<TR>






<TD><font
<TD></TD>
</TR>

<TR>



</TABLE> <BR>
<INPUT class="button" id="runbutton" onclick="Apply_Image" type="button" value="Apply Image"
name="applyimage">

<INPUT class="button" id="runbutton" onclick="Run Diskpart" type="button" value="Run Diskpart"
name="Run Diskpart">

</P>
</DIV></DIV>
<DIV id=tools>

<Button id=ImageX onclick=doTask('%comspec%')> ImageX </BUTTON> &nbsp;&nbsp;&nbsp;&nbsp;
<Button id=cmd onclick=doTask('%comspec%')> Cmd </BUTTON> &nbsp;&nbsp;&nbsp;&nbsp;
<Button id=Notepad onclick=doTask('notepad')> Notepad </BUTTON> &nbsp;&nbsp;&nbsp;&nbsp;
<Button id=close onclick=self.close()> Quit </BUTTON> &nbsp;&nbsp;&nbsp;&nbsp;
<Button id=reboot onclick=self.navigate('reboot.hta')> Reboot </BUTTON>
</DIV>
</BODY>
</HTML>
This is my fist attempt at building a hta application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top