Solved

HTA Submit Application

Posted on 2009-07-09
5
460 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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