Solved

HTA Submit Application

Posted on 2009-07-09
5
453 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add image on html mail 6 27
html input 8 42
VBA to find and replace multiline text from VBA modules 8 64
AWK Code gives empty file, why? 12 36
Find out what you should include to make the best professional email signature for your organization.
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?
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

840 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