Solved

HTA Submit Application

Posted on 2009-07-09
5
448 Views
Last Modified: 2012-05-07
I have an hta that I built that works great however I want to change the button type to radio, and make it so that only one can be selected, as soon as I do what is needed for that I get script errors. I will past the codes for the working, and none working versions below.
Working Code:

<html>

<head>

<title>Help Desk Interface</title>

<HTA:APPLICATION 

     ID="objTest" 

     APPLICATIONNAME="HTATest"

     SCROLL="yes"

     SINGLEINSTANCE="yes"

>

</head>

<body STYLE="font:14 pt arial; color:white;

 filter:progid:DXImageTransform.Microsoft.Gradient

(GradientType=0, StartColorStr='#000000', EndColorStr='#3399ff')">
 
 

<style type="text/css">

.myclass {color:charcoal; font-family:arial; font-size:70%}

.myheader {color:charcoal; font-family:arial;font-weight:bold; font-size:100%}

</style>

<SCRIPT LANGUAGE="VBScript">
 

Sub Window_OnLoad

	intHeight = 380

	intWidth = 600

	Me.ResizeTo intWidth, intHeight

	Me.MoveTo (screen.width / 2) - (intWidth / 2), (screen.height / 2) - (intHeight / 2)

	Set objNetwork = CreateObject("WScript.Network")

	Set WshShell = CreateObject("WScript.Shell")

End Sub
 

    Sub TestSub

	Set WshShell = CreateObject("WScript.Shell")    

        If Checkbox1.Checked Then

            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckdrahd.bat"

        End If

        If Checkbox2.Checked Then

            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckremedyhd.bat"

        End If

        If Checkbox3.Checked Then

            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\OUTLOOKHD.bat"        

        End If

        If Checkbox4.Checked Then

            WshShell.Run "http://141arwsharepoint/sites/help/Help%20Desk%20Training/Forms/AllItems.aspx"       

        End If

	window.Close   

    End Sub  
 

</SCRIPT>
 

<body>
 

    <br>
 

    <input type="checkbox" name="Checkbox1"> Launch DRA<br>

    <input type="checkbox" name="Checkbox2"> Launch Remedy<br>

    <input type="checkbox" name="Checkbox3"> Launch Outlook<br>

    <input type="checkbox" name="Checkbox4"> Launch Help Desk Tasks Outline<p>

    <input id=runbutton  class="button" type="button" value="Run" name="run_button" onClick="TestSub">
 

</body>
 

Non-Working Code:

<html>

<head>

<title>Help Desk Interface</title>

<HTA:APPLICATION 

     ID="objTest" 

     APPLICATIONNAME="HTATest"

     SCROLL="yes"

     SINGLEINSTANCE="yes"

>

</head>

<body STYLE="font:14 pt arial; color:white;

 filter:progid:DXImageTransform.Microsoft.Gradient

(GradientType=0, StartColorStr='#000000', EndColorStr='#3399ff')">
 
 

<style type="text/css">

.myclass {color:charcoal; font-family:arial; font-size:70%}

.myheader {color:charcoal; font-family:arial;font-weight:bold; font-size:100%}

</style>

<SCRIPT LANGUAGE="VBScript">
 

Sub Window_OnLoad

	intHeight = 380

	intWidth = 600

	Me.ResizeTo intWidth, intHeight

	Me.MoveTo (screen.width / 2) - (intWidth / 2), (screen.height / 2) - (intHeight / 2)

	Set objNetwork = CreateObject("WScript.Network")

	Set WshShell = CreateObject("WScript.Shell")

End Sub
 

    Sub TestSub

	Set WshShell = CreateObject("WScript.Shell")    

        If Check1.Checked Then

            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckdrahd.bat"

        End If

        If Check2.Checked Then

            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckremedyhd.bat"

        End If

	window.Close   

    End Sub  
 

</SCRIPT>
 

<body>
 

    <br>
 

    <input type="radio" name="Check1" value="Check1"> Launch DRA<br>

    <input type="radio" name="Check1" value="Check2"> Launch Remedy<br>

    <br>

    <input id=runbutton  class="button" type="button" value="Run" name="run_button" onClick="TestSub">
 

</body>

Open in new window

0
Comment
Question by:141ANG
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 24820861
You have two radios. You gave them different VALUES and you test the values instead of their names.

I do not normally do VB script, but the radio is now a collection and you need to check it possibly like this:
    Sub TestSub
        Set WshShell = CreateObject("WScript.Shell")    
        If Check1(0).Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckdrahd.bat"
        End If
        If Check1(1).Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckremedyhd.bat"
        End If
        window.Close  
    End Sub  


0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24820880
But why click twice???

And why create a shell twice?

<html>

<head>

<title>Help Desk Interface</title>

<HTA:APPLICATION 

     ID="objTest" 

     APPLICATIONNAME="HTATest"

     SCROLL="yes"

     SINGLEINSTANCE="yes"

>

</head>

<body STYLE="font:14 pt arial; color:white;

 filter:progid:DXImageTransform.Microsoft.Gradient

(GradientType=0, StartColorStr='#000000', EndColorStr='#3399ff')">

 

 

<style type="text/css">

.myclass {color:charcoal; font-family:arial; font-size:70%}

.myheader {color:charcoal; font-family:arial;font-weight:bold; font-size:100%}

</style>

<SCRIPT LANGUAGE="VBScript">

 

Sub Window_OnLoad

        intHeight = 380

        intWidth = 600

        Me.ResizeTo intWidth, intHeight

        Me.MoveTo (screen.width / 2) - (intWidth / 2), (screen.height / 2) - (intHeight / 2)

        Set objNetwork = CreateObject("WScript.Network")

        Set WshShell = CreateObject("WScript.Shell")

End Sub

Sub TestSub1

  WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckdrahd.bat"

  window.Close   

End Sub  

Sub TestSub2

  WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckremedyhd.bat"

  window.Close   

End Sub  

 

</SCRIPT>

 

<body>

 

 

    <input class="button" type="button" name="run_button" onClick="TestSub1" value="Launch DRA">

    <input class="button" type="button" name="run_button" onClick="TestSub2" value="Launch Remedy">

 

</body>

Open in new window

0
 
LVL 1

Author Comment

by:141ANG
ID: 24823692
this last script looked promising but it returns an error on click

Line: 29
Char: 3
Error: Object required: 'WshShell'
Code: 0
URL: file:///K:/Automation/LoginType.hta
0
 
LVL 1

Author Closing Comment

by:141ANG
ID: 31601755
This was exactly what I needed
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24824624
Then make WshShell global in scope
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now